Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 295 296 [297] 298 299 ... 710

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

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4440 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.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

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

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4442 on: March 12, 2019, 05:05:06 PM »

Hmm.

So, do Pirates never get to have Capitals?
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4443 on: March 12, 2019, 05:43:12 PM »

I'm not sure exactly what you mean.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4444 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.
« Last Edit: March 12, 2019, 07:36:02 PM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4445 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.)
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4446 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)
Logged
My mods


xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4447 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]
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4448 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.
Logged
My mods


xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4449 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.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4450 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.
Logged
My mods


Blothorn

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

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4452 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.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4453 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
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4454 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).
Logged
Pages: 1 ... 295 296 [297] 298 299 ... 710