Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 697 698 [699] 700 701 ... 711

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24163
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10470 on: February 12, 2024, 01:43:48 PM »

Could the exception I reported here 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).
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10471 on: February 12, 2024, 02:49:58 PM »

Could the exception I reported here 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%
« Last Edit: February 12, 2024, 02:57:44 PM by Sundog »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24163
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10472 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!
« Last Edit: February 12, 2024, 03:50:42 PM by Alex »
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10473 on: February 12, 2024, 04:10:01 PM »

No worries! Really appreciate you looking into it!

Matheld

  • Lieutenant
  • **
  • Posts: 87
  • Warm to the Touch
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10474 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.
Logged

Alex

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

Killer of Fate

  • Admiral
  • *****
  • Posts: 703
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10476 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]
« Last Edit: February 15, 2024, 07:20:49 AM by Killer of Fate »
Logged

Xerdies

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

JAL28

  • Commander
  • ***
  • Posts: 217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10478 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]
Logged

Histidine

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

JAL28

  • Commander
  • ***
  • Posts: 217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10480 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.)
« Last Edit: February 17, 2024, 07:29:33 AM by JAL28 »
Logged

Uthred

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

nathan67003

  • Commander
  • ***
  • Posts: 159
  • Excellent imagination, mediocre implementation.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10482 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.
Logged
I have some ideas but can't sprite worth a damn and the ideas imply really involved stuff which I've no clue how to even tackle.

Histidine

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24163
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10484 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".
Logged
Pages: 1 ... 697 698 [699] 700 701 ... 711