Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 370 371 [372] 373 374 ... 710

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

Cabbs

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

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5566 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
« Last Edit: November 03, 2019, 06:49:06 AM by TrashMan »
Logged

Alex

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

Yunru

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

Cabbs

  • Ensign
  • *
  • Posts: 24
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5569 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!
« Last Edit: November 03, 2019, 10:41:00 AM by Cabbs »
Logged

RustyCabbage

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

Alex

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

}
« Last Edit: November 03, 2019, 05:48:43 PM by Morrokain »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5573 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.
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 #5574 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."
« Last Edit: November 03, 2019, 06:08:16 PM by Morrokain »
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 683
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5575 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!

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5576 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.
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 #5577 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.
« Last Edit: November 03, 2019, 08:06:27 PM by Morrokain »
Logged

Alex

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

King Alfonzo

  • Admiral
  • *****
  • Posts: 683
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5579 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?
Pages: 1 ... 370 371 [372] 373 374 ... 710