Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: mendonca on May 20, 2019, 06:29:14 AM

Title: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: mendonca on May 20, 2019, 06:29:14 AM
I'm posting this for information, and slightly reluctantly, however I can't quite decide whether it is intended behaviour or not and seems sensible to at least raise it. At the very least it appears to point to some weirdness which might be worth looking at, regardless - or perhaps can be quickly explained.

I'll try and be clear about this, apologies if it stops making sense ...


The crux of the issue is that I was finding that my 'remnant-like' stations / factions were not creating live fleets, in my generated 'remnant-like' systems.

All seemed to be nearly working - It would generate the fleets, in new systems, all tagged with my set themes and all as expected (e.g. at inner system jump points or from Stations) however they would NOT populate with ships I intended for them. Empty fleet would, effectively, immediately despawn when player arrives in locality.

The problem was found to be resolved by changing the 'tag' in the ship_data.csv and generating a completely new tag for the faction fleet ships. Existing mod 'blueprint tags' didn't appear to work for this.


GENERALLY THIS IS WHAT I DID

a) Use fleetFactoryV3 to make fleet from my .faction in a new remnant system. May be from battle station or just at a set point in space. Behaviour very closely mimicking that of the Remnants in terms of generation. Ship list I want to generate from is via (e.g.) Junk_Pirates_BP tag, as defined in .faction file for knownShips.
No ships generate in fleet. Fleet immediately despawns upon teleportation (via console commands) directly to fleet position. Stations continually spew out blank fleets.

b) Try other faction ship tags (all inevitably part of a BP set, as this seems to make sense, right?)
Same behaviour.

c) Try base_bp tag in .faction file for knownShips.
Ships generate in fleets, but only those with base_bp as tag (Ventures etc.) and not those with my custom BP tags.

d) Try market to null; quality overrides, custom_bp tag into shipsWhenImporting etc.
No change, empty fleets or full of base_bp ships.

d) Add new discrete tags to ships that I want to appear in 'special' fleets. Add this tag to the .faction file.
Ships spawn as originally expected! (I will note this is actually in line with the 'remnant' tag for vanilla case which does not link to a blueprint set)


I can't directly identify why my fix works, but to me it points potentially to things working differently to how it may be planned - and may suggest a potential blocker for widening out the mechanisms already in place due perhaps to some unintended checks / weirdness in the code.

My theory is that something in the code is locking out those types of ships which are generated via a BP / Heavy Industry - as it makes sense that there will be a check in there for something like this to stop it. I may well be wrong.

No apparently present overrides are working to offset this in this case (e.g. setting source market to null; which appears to be a designed-for case in fleetfactoryV3 or giving quality overrides to the fleetfactory).

Cheers,

mendonca
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: Alex on May 20, 2019, 08:58:27 AM
(Let me move this to Modding; this may well be a bug, but that subforum is more conducive to a longer conversation.)

Are you always adding to shipsWhenImporting alongside knownShips? I would guess your faction doesn't have any colonies with ship production, and would therefore only have access to hulls from the "shipsWhenImporting" section; adding stuff to knownShips would have no effect in that situation.

One thing to consider: ships available to a faction only get refreshed when you start a new campaign. Is it possible that you had stuff in knownShips (which didn't work), then tried doing a bunch of stuff that should've worked (but didn't due to the game not picking it up), and then started a new game where stuff in the second d) step actually worked?


(The reason it doesn't pick up stuff is that available ships can be changed dynamically, right - it'd be odd if say some event removed a faction's access to a ship, and that got reset next time the game was loaded. It can definitely be confusing and inconvenient when working on a faction, though...)
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: mendonca on May 20, 2019, 12:27:15 PM
(Let me move this to Modding; this may well be a bug, but that subforum is more conducive to a longer conversation.)

Yep, makes sense.

Quote
Are you always adding to shipsWhenImporting alongside knownShips? I would guess your faction doesn't have any colonies with ship production, and would therefore only have access to hulls from the "shipsWhenImporting" section; adding stuff to knownShips would have no effect in that situation.
Honestly, not always. But I've tried quite a lot of iterations of various things to try and work round it. I'm reasonably sure it includes adding this in (albeit don't have all the .faction files I've used for this troubleshooting exercise so can never say never).

Would you explicitly need to add in knownShips and shipsWhenImporting? Would something in shipsWhenImporting spawn regardless of knownShips? (I've most certainly tried introducing additional custom bp tags to shipsWhenImporting; can't 100% verify right now that I've added both to shipsWhenImporting AND knownShips - until I got it 'fixed' - in fairness this sounds like something my stubbornness gene(s?) would almost definitely have convinced me in a really sinister subconscious way that I wouldn't need to do this.)

Quote
One thing to consider: ships available to a faction only get refreshed when you start a new campaign. Is it possible that you had stuff in knownShips (which didn't work), then tried doing a bunch of stuff that should've worked (but didn't due to the game not picking it up), and then started a new game where stuff in the second d) step actually worked?

(The reason it doesn't pick up stuff is that available ships can be changed dynamically, right - it'd be odd if say some event removed a faction's access to a ship, and that got reset next time the game was loaded. It can definitely be confusing and inconvenient when working on a faction, though...)

Every test session was started with new game - then using console commands quickly iterate over the systems to find a relevant theme; then jump and quickly search for a test case (battlestation, normally).
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: Snrasha on May 20, 2019, 12:51:43 PM
Hello,

My Remnant-like faction, SAD, do not seems to have a problem, do not hesitate to look on it(Look the code on bitbucket).
Spoiler
(https://i.imgur.com/MakXwGF.png)
[close]
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: Alex on May 20, 2019, 01:10:19 PM
Would you explicitly need to add in knownShips and shipsWhenImporting? Would something in shipsWhenImporting spawn regardless of knownShips? (I've most certainly tried introducing additional custom bp tags to shipsWhenImporting; can't 100% verify right now that I've added both to shipsWhenImporting AND knownShips - until I got it 'fixed' - in fairness this sounds like something my stubbornness gene(s?) would almost definitely have convinced me in a really sinister subconscious way that I wouldn't need to do this.)

I'm not actually sure - I want to say it doesn't need to be added to both, but looking at the code, there's one case where I think it *would* need to be added to both to work.

Every test session was started with new game - then using console commands quickly iterate over the systems to find a relevant theme; then jump and quickly search for a test case (battlestation, normally).

If it's not too much of a hassle - could you send me a link to a version where it's in both shipsWhenImporting and knownShips, that you think should work but doesn't? I could take a look and see what's going on.

Re-reading your initial post, I'm not actually clear on what the conditions are - i.e. "Junk_Pirates_BP" from point a) sounds like "new discrete tags" from point d2), so I'm not exactly sure what you mean here.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: mendonca on May 20, 2019, 02:33:20 PM
If it's not too much of a hassle - could you send me a link to a version where it's in both shipsWhenImporting and knownShips, that you think should work but doesn't? I could take a look and see what's going on.
No I can't. I've just checked and this actually does resolve the issue.  :-[

(I obviously just did not check this; I even went through this with somebody else as a potential solution, tested it, and told them it didn't work; I think some of my tags just look very similar and I've passed this one over through error)

Quote
Re-reading your initial post, I'm not actually clear on what the conditions are - i.e. "Junk_Pirates_BP" from point a) sounds like "new discrete tags" from point d2), so I'm not exactly sure what you mean here.

So; as above - solving the issue obviously just meant taking it back to first principles. Creating a whole new set of tags allowed me to overcome the issue by ... eh ... doing the set up properly rather than just thinking I've done it properly.

So it appears that we DO need both shipsWhenImporting and knownShips for factions without ship production ... heh ... sorry for this one and thank you for looking into it, I am glad it's clear now at least.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: Alex on May 20, 2019, 03:05:52 PM
Whew, glad this works - no worries! Apologies, for, ah, not documenting it better/at all; can totally see how it would be a pain to sort through.

Btw, I looked into it a bit more: looks like the only case where "shipsWhenImporting" that are *not* in "knownShips" will get used is if the ship pick mode is ShipPickMode.ALL.

I think the way it works now is intentional - the idea, iirc, is that you could configure "shipWhenImporting" to have a more extensive list than the faction knows, in anticipation of it possibly learning those later on. The "ALL" pick mode is a way to get around that, I guess? The more I think about it the more needlessly-future-proofed that aspect of it seems, but, well, at least now we've got some certainty about how it works.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: mendonca on May 20, 2019, 11:42:12 PM
Excellent, thank you.  :)
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: SafariJohn on May 21, 2019, 11:02:24 AM
I think I ran into this and I solved it by manually setting my FleetParamsV3's mode variable. In my case, I used Misc.getShipPickMode(market, factionId), but setting it directly to one of the FactionAPI.ShipPickMode values works too.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: TrashMan on May 22, 2019, 01:48:24 AM
One thing to consider: ships available to a faction only get refreshed when you start a new campaign.

May I ask why? It doesn't seem a like a good decision at first glance.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: mendonca on May 22, 2019, 03:22:35 AM
(The reason it doesn't pick up stuff is that available ships can be changed dynamically, right - it'd be odd if say some event removed a faction's access to a ship, and that got reset next time the game was loaded. It can definitely be confusing and inconvenient when working on a faction, though...)
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: TrashMan on May 23, 2019, 12:50:51 AM
Hello,

My Remnant-like faction, SAD, do not seems to have a problem, do not hesitate to look on it(Look the code on bitbucket).
Spoiler
(https://i.imgur.com/MakXwGF.png)
[close]

You mentioned the code, but provided no link to it.
I am interested in it too.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: Snrasha on May 24, 2019, 12:59:40 PM
Hello,

My Remnant-like faction, SAD, do not seems to have a problem, do not hesitate to look on it(Look the code on bitbucket).
Spoiler
(https://i.imgur.com/MakXwGF.png)
[close]

You mentioned the code, but provided no link to it.
I am interested in it too.
https://bitbucket.org/Snrasha/sad/src/master/
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: TrashMan on May 24, 2019, 01:48:53 PM
Thanks...

That's a lot of files to get some custom faction fleets spawning. ???
Is it just me or was it simpler before?

Also, compiling a .jar is no longer required for everything to work, right?
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: Snrasha on May 24, 2019, 01:52:05 PM
Thanks...

That's a lot of files to get some custom faction fleets spawning. ???
Is it just me or was it simpler before?

Also, compiling a .jar is no longer required for everything to work, right?
You need a jar, like always, why you will not longer require a jar? ^^


Else, no,  i have forget to clean my mod of a custom raid than i have tried to made, but forget to remove.
Look src.data.scripts.world.SAD_Gen

You have just 3-4 files for that.
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: TrashMan on May 24, 2019, 02:15:00 PM
I have 1 faction (AI) that should work like Remnant. With bases they spawn near, but I want them to be aggressive (raids)

I also have another faction that does NOT have bases. I just want them to have fleets spawn in random system and travel to random populated worlds to either attacks or scout.

This is the OLD code that definitely doesn't work anymore (still uses old FleetFactory):
Code
package data.scripts.world;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.fleets.FleetFactory;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.ShipRoles;
import org.apache.log4j.Logger;

import java.util.Random;

import static com.fs.starfarer.api.Global.getSector;



StarSystemAPI system = Global.getSector().getStarSystems().get(...);
if (system.getAsteroids().size() == 0) {
//does not have asteroids
}
else {
//has asteroids
}



public class FleetSpawner {

    public static Logger log = Global.getLogger(FleetSpawner.class);

    public static void rock_spawner()
    {
        int fleets = getSector().getEntitiesWithTag("generated_rock").size();
        //Global.getSector().getCampaignUI().addMessage("Total number of AI fleets: "+ai_fleets);

                String target_name = "";
                target_name = xle_mining_sites[rnd.nextInt(xle_mining_sites.length)];
                SectorEntityToken target = getSector().getStarSystem(target_name).getStar();

Random rnd;
for (StarSystemAPI system : Global.getSector().getStarSystems()) {
if (system.getAsteroids().size() == 0) {
//does not have asteroids
}
else {
//has asteroids
if (rnd.nextInt(8) >= 4) {
CampaignFleetAPI fleet = FleetFactory.createGenericFleet("ROCK", "Beast", 1f, 0);
fleet.getFleetData().sort();
FleetFactory.finishAndSync(fleet);
system.getContainingLocation().addEntity(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);

                    log.info("Spawned a Rock Fly to feed at "+target.getName()+" in "+target_name+" system");


}
}
}
    }


    public static void AI_spawner()
    {
        int ai_fleets = getSector().getEntitiesWithTag("generated_ai").size();
        //Global.getSector().getCampaignUI().addMessage("Total number of AI fleets: "+ai_fleets);



        if (ai_fleets <= 2)
        {
            String spawn_name = "telmun_label_id";
            String target_name = "";
            SectorEntityToken spawn = getSector().getEntityById(spawn_name);
            int fleets_to_spawn = 3;

            Script ai_increase = createAIscript(spawn);

            for (int i=0; i < fleets_to_spawn; i++)
            {

                SectorEntityToken target1 = getSector().getStarSystems(random).getCenter();
                SectorEntityToken target2 = getSector().getStarSystems(random).getCenter();
                SectorEntityToken target3 = getSector().getStarSystems(random).getCenter();

                CampaignFleetAPI fleet = FleetFactory.createGenericFleet("AI", "Scouts", 1f, 0);

                if (spawn.hasTag("+5"))
                {
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_LARGE, 1, fleet);
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_MEDIUM, 1, fleet);
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_MEDIUM, 1, fleet);
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_MEDIUM, 1, fleet);
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_MEDIUM, 1, fleet);
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_SMALL, 1, fleet);
                    getSector().getFaction("AI").pickShipAndAddToFleet(ShipRoles.COMBAT_SMALL, 1, fleet);

                    fleet.getFleetData().sort();
                    FleetFactory.finishAndSync(fleet);

                    spawn.getContainingLocation().addEntity(fleet);
                    fleet.setLocation(spawn.getLocation().x + (float)Math.random()*1000, spawn.getLocation().y - (float)Math.random()*1000);
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target1, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ATTACK_LOCATION, target1, 30, "attacking "+target1.getName());
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, spawn, 1000, "traveling to an unknown destination", ai_increase);
                    fleet.addTag("generated_ai_assaulters");
                    fleet.setName("Eradicator Fleet");
                    spawn.removeTag("+5");
                    spawn.removeTag("+4");
                    spawn.removeTag("+3");
                    spawn.removeTag("+2");
                    spawn.removeTag("+1");

                    log.info("Spawned an AI Eradicator fleet to attack "+target1.getName());

                }

                else
                {

                    fleet.getFleetData().sort();
                    FleetFactory.finishAndSync(fleet);

                    spawn.getContainingLocation().addEntity(fleet);
                    fleet.setLocation(spawn.getLocation().x + (float)Math.random()*1000, spawn.getLocation().y - (float)Math.random()*1000);
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target1, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, target1, 7, "surveying "+target1.getName());
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target2, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, target2, 7, "surveying "+target2.getName());
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target3, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, target3, 7, "surveying "+target3.getName());
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, spawn, 1000, "traveling to an unknown destination", ai_increase);
                    fleet.addTag("generated_ai");


                    log.info("Spawned AI to scout "+target1.getName()+", "+target2.getName()+ " and "+target3.getName());

                    //Global.getSector().getCampaignUI().addMessage("Generated AI fleet to explore "+target1.getName()+", "+target2.getName()+" and "+target3.getName());
                }

                fleet.getCargo().addCommodity("rare_metals", fleet.getCargo().getSpaceLeft()/2);
                fleet.getCargo().addCommodity("volatiles", fleet.getCargo().getSpaceLeft()/2);
            }
        }
    }

    public static void aliens_spawner()
    {
        int ai_fleets = getSector().getEntitiesWithTag("generated_alien").size();
        //Global.getSector().getCampaignUI().addMessage("Total number of AI fleets: "+ai_fleets);


        if (ai_fleets <= 2)
        {
            String spawn_name = "cathedral_label_id";
            String target_name = "";
            SectorEntityToken spawn = getSector().getEntityById(spawn_name);
            int fleets_to_spawn = 4;

            Script ai_increase = createAIscript(spawn);

            for (int i=0; i < fleets_to_spawn; i++)
            {

                SectorEntityToken target = getSector().getStarSystems(random).getCenter();


                if (spawn.hasTag("+5"))
                {
                    CampaignFleetAPI fleet = FleetFactory.createGenericFleet("ALIENS", "Abductors", 1f, 0);
                    Script harvest = createHarvestscript(fleet);

                    getSector().getFaction("ALIENS").pickShipAndAddToFleet(ShipRoles.CARRIER_SMALL, 1, fleet);
                    getSector().getFaction("ALIENS").pickShipAndAddToFleet(ShipRoles.COMBAT_MEDIUM, 1, fleet);
                    getSector().getFaction("ALIENS").pickShipAndAddToFleet(ShipRoles.COMBAT_SMALL, 1, fleet);
                    getSector().getFaction("ALIENS").pickShipAndAddToFleet(ShipRoles.COMBAT_SMALL, 1, fleet);

                    fleet.getFleetData().sort();
                    FleetFactory.finishAndSync(fleet);

                    spawn.getContainingLocation().addEntity(fleet);
                    fleet.setLocation(spawn.getLocation().x + (float) Math.random() * 1000, spawn.getLocation().y - (float) Math.random() * 1000);
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, target, 14, "abducting populace of "+target.getName(), harvest);
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, spawn, 1000, "traveling to an unknown destination", ai_increase);
                    fleet.addTag("generated_alien_abductors");
                    spawn.removeTag("+5");
                    spawn.removeTag("+4");
                    spawn.removeTag("+3");
                    spawn.removeTag("+2");
                    spawn.removeTag("+1");

fleet.getCargo().addCommodity("rare_metals", fleet.getCargo().getSpaceLeft()/2);
fleet.getCargo().addCommodity("volatiles", fleet.getCargo().getSpaceLeft()/2);

                    log.info("Spawned Alien Abductors to harrass "+target.getName());
                    //Global.getSector().getCampaignUI().addMessage("Generated AI retaliation fleet to attack "+target1.getName());
                }

                else
                {
                    CampaignFleetAPI fleet = FleetFactory.createGenericFleet("ALIENS", "Probe", 1f, 0);

                    fleet.getFleetData().sort();
                    FleetFactory.finishAndSync(fleet);

                    spawn.getContainingLocation().addEntity(fleet);
                    fleet.setLocation(spawn.getLocation().x + (float) Math.random() * 1000, spawn.getLocation().y - (float) Math.random() * 1000);
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, target, 7, "probing populace of "+target.getName());
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, spawn, 1000, "traveling to an unknown destination", ai_increase);
                    fleet.addTag("generated_alien");

fleet.getCargo().addCommodity("rare_metals", fleet.getCargo().getSpaceLeft()/3);
fleet.getCargo().addCommodity("volatiles", fleet.getCargo().getSpaceLeft()/3);



                    log.info("Spawned Alien fleet to probe "+target.getName());
                    //Global.getSector().getCampaignUI().addMessage("Generated AI fleet to explore "+target1.getName()+", "+target2.getName()+" and "+target3.getName());
                }
            }
        }
    }

    private static Script createAIscript(final SectorEntityToken spawn)
    {
        return new Script()
        {
            public void run()
            {
                if (!spawn.hasTag("+5") && spawn.hasTag("+4")) spawn.addTag("+5");
                else if (!spawn.hasTag("+4") && spawn.hasTag("+3")) spawn.addTag("+5");
                else if (!spawn.hasTag("+3") && spawn.hasTag("+2")) spawn.addTag("+5");
                else if (!spawn.hasTag("+2") && spawn.hasTag("+1")) spawn.addTag("+5");
                else if (!spawn.hasTag("+1")) spawn.addTag("+5");

                log.info("Increased AI or Alien activity counter");
            }
        };
    }

    private static Script createHarvestscript(final CampaignFleetAPI fleet)
    {
        return new Script()
        {
            public void run()
            {
                fleet.getCargo().addCommodity(Commodities.ORGANS, fleet.getCargo().getSpaceLeft()/2);

                log.info("Loaded the Abductors with harvested organs");
            }
        };
    }




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);


            vns_firstfleet.getCargo().addCrew(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");
        }
    }





    private static String [] rsf_markets =
            {
                    "jangala",
                    "barnard_guard_station",
                    "barnard_gas_station",
                    "chugun",
                    "vostok",
                    "gagarin_shipyard",
                    "gagarin_scrapyard",
                    "denisovka",
                    "denisovka_station",
                    "stal",
                    "rzhavaya",
                    "rzhavaya_sentry_station",
                    "plavka",
            };

    private static String [] isa_markets =
            {
                    "dwarf",
                    "argos_shipyard",
                    "sterilla",
                    "darloth_station",
                    "washingtonia",
                    "jorgia",
                    "ulysses",
                    "simpson",
                    "hiram",
                    "washingtonia",
                    "danbridge",
            };

    private static String [] uin_markets =
            {
                    "achiles_scrapyard",
                    "sands",
                    "archemedes",
                    "centronom_fabricator",
                    "freya",
                    "vella",
                    "selena",
                    "snowball",
            };

    private static String [] xle_markets =
            {
                    "khabara",
                    "khabara_a",
                    "khabara_a_station",
                    "pango",
                    "procyon_guard_station",
                    "omio",
                    "moizi",
                    "uomoz_scrapyard",
            };

    private static String [] ffs_markets =
            {
                    "unity",
                    "adra_station1",
                    "adra_station2",
                    "freedom",
                    "impalo_station",
                    "liberty",
                    "kores_station1",
                    "independence",
            };

    private static String [] all_spawns =
            {
                    "jangala",
                    "barnard_guard_station",
                    "barnard_gas_station",
                    "chugun",
                    "vostok",
                    "gagarin_shipyard",
                    "gagarin_scrapyard",
                    "denisovka",
                    "denisovka_station",
                    "stal",
                    "rzhavaya",
                    "rzhavaya_sentry_station",
                    "plavka",
                    "dwarf",
                    "argos_shipyard",
                    "sterilla",
                    "darloth_station",
                    "washingtonia",
                    "jorgia",
                    "ulysses",
                    "simpson",
                    "hiram",
                    "washingtonia",
                    "danbridge",
                    "achiles_scrapyard",
                    "sands",
                    "archemedes",
                    "centronom_fabricator",
                    "freya",
                    "vella",
                    "selena",
                    "snowball",
                    "khabara",
                    "khabara_a",
                    "khabara_a_station",
                    "pango",
                    "procyon_guard_station",
                    "omio",
                    "moizi",
                    "uomoz_scrapyard",
                    "vixis",
                    "vaynar_guard_station",
                    "avalon",
                    "avalon_shipyard",
"vaynar_pirate",
            };

    private static String [] vns_markets =
            {
                    "vixis",
                    "vaynar_guard_station",
                    "avalon",
                    "avalon_shipyard",
                    "helios",
            };

}
Title: Re: [0.9.1a] 'Remnant-like' mod factions - Fleet generation issues - Ship Tags
Post by: TrashMan on May 25, 2019, 09:37:18 AM
There are plenty of tutorials on Starsector modding, but none that cover creating special factions (no markets, just patroling or raiding systems).

That should be rectified.