Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Uniquifying the Factions, Part 2 (04/30/22)

Pages: 1 ... 394 395 [396] 397 398 ... 593

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

Alex

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

Mongreal

  • Ensign
  • *
  • Posts: 46
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5926 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.
« Last Edit: January 06, 2020, 01:13:45 PM by Mongreal »
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 2484
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5927 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, here).

There's actually an example in vanilla, too: data\scripts\world\systems\Galatia.java
Logged

Silveressa

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5928 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?"
Logged

Alex

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

Silveressa

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5930 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!
Logged

creature

  • Captain
  • ****
  • Posts: 359
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5931 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.
Logged

Alex

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

creature

  • Captain
  • ****
  • Posts: 359
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5933 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?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20460
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5934 on: January 12, 2020, 06:56:08 PM »

... yes! Nice. At least, it seems like that would work.
Logged

prav

  • Commander
  • ***
  • Posts: 144
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5935 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.
« Last Edit: January 16, 2020, 04:28:35 AM by prav »
Logged

shoi

  • Captain
  • ****
  • Posts: 498
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5936 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?
Logged

Alex

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

Morrokain

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20460
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5939 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.
Logged
Pages: 1 ... 394 395 [396] 397 398 ... 593