Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95a is out! (03/26/21); Blog post: Skill Changes, Part 2 (07/15/21)

Pages: 1 ... 507 508 [509] 510 511 ... 532

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

shoi

  • Captain
  • ****
  • Posts: 380
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7620 on: June 24, 2021, 02:13:21 AM »

Where would I look at to try to replicate the Story Point Officer Promotion event that sometimes pops up and lasts a few months?
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 2101
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7621 on: June 24, 2021, 09:28:04 AM »

Where would I look at to try to replicate the Story Point Officer Promotion event that sometimes pops up and lasts a few months?

You are looking for com.fs.starfarer.api.impl.campaign.intel.PromoteOfficerIntel.java in starfarer.api.zip. The intel events are created in com.fs.starfarer.api.impl.campaign.FleetEncounterContext.java on line 2038.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19106
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7622 on: June 24, 2021, 10:14:48 AM »

If I were making a system that makes guns use a secondary damage type without losing the primary where would I look in the documentation?

The end goal is an attack destroyer with a system that gives its guns bonus HE damage but slashes its range while active.

You'd probably want to have a look at DamageDealtModifier and have the system add/remove that to the ship. RangedSpecialization (the implementation of the skill) might be a decent starting point to look at.
Logged

shoi

  • Captain
  • ****
  • Posts: 380
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7623 on: June 24, 2021, 01:04:49 PM »

Where would I look at to try to replicate the Story Point Officer Promotion event that sometimes pops up and lasts a few months?

You are looking for com.fs.starfarer.api.impl.campaign.intel.PromoteOfficerIntel.java in starfarer.api.zip. The intel events are created in com.fs.starfarer.api.impl.campaign.FleetEncounterContext.java on line 2038.

oof, thats  a meaty script! Thanks for going out of your way to give me the line number, even  :)
« Last Edit: June 24, 2021, 01:07:25 PM by shoi »
Logged

alaricdragon

  • Ensign
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7624 on: June 24, 2021, 10:25:34 PM »

I find myself wanting to make a button that can basically do exactly what the 'establish a colony' button can do, so i can have some different requirements for this button, however am having some troubles. the colony i make
dose not display faction name,
dose not show up on the players colony menu,
i don't know if the player gets any income from said colony, but is no income/upkeep visible
i cant build industry or structures, nor can i add administrators.


in short, i think im doing something wrong, but i have no idea were to even start.
here is my code, its adapted from something in Nexerelin, as it was recommended to me.
yes i know its a mess, but at this point I'm sick of guessing what's wrong, and trying to adapt something pointlessly.
Code
    public static void createColonyStatic(MarketAPI market, PlanetAPI planet,
                                          FactionAPI faction)
    {
        String factionId = faction.getId();

        market.setSize(3);
        market.addCondition("population_3");
        market.setFactionId(factionId);
        market.setPlanetConditionMarketOnly(false);
        //market.getMemoryWithoutUpdate().set(MEMORY_KEY_COLONY, true);
        //market.getMemoryWithoutUpdate().set(ExerelinConstants.MEMKEY_MARKET_STARTING_FACTION, factionId);

        // rename generic-name worlds
        if (market.getName().startsWith(planet.getStarSystem().getBaseName() + " ")) {
            String tag = NameGenData.TAG_PLANET;
            if (planet.isMoon()) tag = NameGenData.TAG_MOON;
            String newName = ProcgenUsedNames.pickName(tag, null, null).nameWithRomanSuffixIfAny;
            market.setName(newName);
            planet.setName(newName);
            ProcgenUsedNames.notifyUsed(newName);
        }

        if (market.hasCondition(Conditions.DECIVILIZED))
        {
            market.removeCondition(Conditions.DECIVILIZED);
            market.addCondition(Conditions.DECIVILIZED_SUBPOP);
        }
        market.addIndustry(Industries.POPULATION);

        // set growth level to 0%
        if (!faction.isPlayerFaction()) {
            ImmigrationPlugin plugin = getImmigrationPlugin(market);
            float min = plugin.getWeightForMarketSize(market.getSize());
            market.getPopulation().setWeight(min);
            market.getPopulation().normalize();
            market.getMemoryWithoutUpdate().set("$nex_delay_growth", true, 10);
        }

        //NexFactionConfig config = NexConfig.getFactionConfig(factionId);
        //if (config.freeMarket)
        //{
        //    market.getMemoryWithoutUpdate().set("$startingFreeMarket", true);
        //    market.setFreePort(true);
        //}
        //REMOVED TEST 0
        //market.getTariff().modifyFlat("generator", Global.getSector().getFaction(factionId).getTariffFraction());
        //NexUtilsMarket.setTariffs(market);

        // submarkets
        //SectorManager.updateSubmarkets(market, Factions.NEUTRAL, factionId);
        //REMOVED TEST 0
        //market.addSubmarket(Submarkets.SUBMARKET_STORAGE);
        market.setSurveyLevel(MarketAPI.SurveyLevel.FULL);
        for (MarketConditionAPI cond : market.getConditions())
        {
            cond.setSurveyed(true);
        }

        Global.getSector().getEconomy().addMarket(market, true);
        market.getPrimaryEntity().setFaction(factionId); // http://fractalsoftworks.com/forum/index.php?topic=8581.0

        //if (!fromDeciv) {
        //    NexUtilsMarket.addPerson(Global.getSector().getImportantPeople(),
        //            market, Ranks.CITIZEN, Ranks.POST_ADMINISTRATOR, true);
            //market.setImmigrationIncentivesOn(true);
        //}
        //if (fromDeciv) {
            market.addIndustry(Industries.SPACEPORT);
        //}

        //ColonyManager.buildIndustries(market);
        //ColonyManager.getManager().processNPCConstruction(market);

        // planet desc change
        //MarketDescChanger.getInstance().reportMarketTransfered(market, faction,
                //Global.getSector().getFaction(Factions.NEUTRAL), false, false, null, 0);
    }
so anyone know to make something like this work?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19106
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7625 on: June 25, 2021, 10:57:24 AM »

One thing you need to do for a player-owned colony is:
market.setPlayerOwned(true)

Not sure if that'd cover everything you have going on, though.
Logged

Ruddygreat

  • Ensign
  • *
  • Posts: 9
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7626 on: June 25, 2021, 01:16:24 PM »

Is there a way to get missiles to use the mote ai?
I've been messing around (without an IDE, currently unable to use one) and tried setting a missile's type to "mote", then set a missile weapon to fire the existing mote projectile, although both times the resulting missiles don't move on their own - is it a part of the ziggurat's system?
« Last Edit: June 25, 2021, 01:18:40 PM by Ruddygreat »
Logged

Yunru

  • Admiral
  • *****
  • Posts: 927
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7627 on: June 25, 2021, 02:09:05 PM »

So getting back to this code, now that it doesn't crash, I can't figure out why it simply does... Nothing. I'd thought/hoped it would increase the firing arc of any turret mounts, but both the refit screen and testing shows that it doesn't.

Code
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, ShipAPI ship, String id) {
for (WeaponAPI w : ship.getAllWeapons()) {
WeaponSlotAPI m = w.getSlot();
if (m.isTurret() != true) continue;
float arc = m.getArc();
arc = arc*1.5f;
m.setArc(arc);
}
}

Techpriest

  • Commander
  • ***
  • Posts: 235
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7628 on: June 26, 2021, 12:50:18 PM »

So getting back to this code, now that it doesn't crash, I can't figure out why it simply does... Nothing. I'd thought/hoped it would increase the firing arc of any turret mounts, but both the refit screen and testing shows that it doesn't.

Code
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, ShipAPI ship, String id) {
for (WeaponAPI w : ship.getAllWeapons()) {
WeaponSlotAPI m = w.getSlot();
if (m.isTurret() != true) continue;
float arc = m.getArc();
arc = arc*1.5f;
m.setArc(arc);
}
}
Afaik weapons aren't made (BeforeShipCreation code-wise) so there's nothing for it to modify except built-ins or something. You have to use ApplyEffectsAfterShipCreation. Also I'm unaware if you can even add ShipAPI ship to the command.

Morrokain

  • Admiral
  • *****
  • Posts: 1950
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7629 on: June 26, 2021, 02:01:21 PM »

Afaik weapons aren't made (BeforeShipCreation code-wise) so there's nothing for it to modify except built-ins or something. You have to use ApplyEffectsAfterShipCreation. Also I'm unaware if you can even add ShipAPI ship to the command.

You should be able to cast the CombatEntityAPI that you get from the MutableShipStatsAPI.getEntity() to a ShipAPI.

Example:
Code
            ShipAPI ship = null;
            if (stats.getEntity() instanceof ShipAPI) {
                ship = (ShipAPI)stats.getEntity();
            }

            if (ship != null) {
               // Do the thing.
            }

If that has issues for some reason, then you could always use:

Code
	@Override
public void advanceInCombat(ShipAPI ship, float amount) {
}

 - and set/check for a static boolean to prevent the script from constantly running.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 2101
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7630 on: June 26, 2021, 04:42:51 PM »

So getting back to this code, now that it doesn't crash, I can't figure out why it simply does... Nothing. I'd thought/hoped it would increase the firing arc of any turret mounts, but both the refit screen and testing shows that it doesn't.
Afaik weapons aren't made (BeforeShipCreation code-wise) so there's nothing for it to modify except built-ins or something. You have to use ApplyEffectsAfterShipCreation. Also I'm unaware if you can even add ShipAPI ship to the command.

You can't add parameters to a method override. It creates a new method. Naturally, the core code will never call that new method.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 927
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7631 on: June 27, 2021, 02:05:44 AM »

Hmm, both before and after don't have an effect (even calling the method with the correct number of parameters, heh).

Is there any examples of advanceInCombat other than PeriodicMissileReload?

NinjaSiren

  • Ensign
  • *
  • Posts: 45
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7632 on: June 27, 2021, 05:51:51 AM »

Good day! I am adding a new weapon for my mod (a large particle/laser weapon) and every time I test it in game this happens:

Spoiler
117873 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.ship.A.G.this.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.G.createBeam(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.E.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.E.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.G.advance(Unknown Source)
   at com.fs.starfarer.combat.systems.G.o00000(Unknown Source)
   at com.fs.starfarer.combat.systems.G.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Here is the weapon's .wpn code:
Spoiler
{
  "id": "hs_polaris_projector",
  "specClass": "beam",
  "type": "ENERGY",
  "size": "LARGE",
  "collisionClass": "RAY",
  "collisionClassByFighter": "RAY_FIGHTER",
  "turretSprite": "graphics/weapons/polaris_projector_turret_base.png",
  "turretGlowSprite": "graphics/weapons/polaris_projector_turret_glow.png",
  "hardpointSprite": "graphics/weapons/polaris_projector_hardpoint_base.png",
  "hardpointGlowSprite": "graphics/weapons/polaris_projector_hardpoint_glow.png",
  "glowColor": [185, 157, 230, 96],
  "hitGlowRadius": 0,
  "turretOffsets": [3, 0],
  "turretAngleOffsets": [ 0 ],
  "hardpointOffsets": [15,0],
  "hardpointAngleOffsets": [ 0 ],
  "beamFireOnlyOnFullCharge": true,
  "fringeColor": [179, 141, 238, 128],
  "coreColor": [80, 51, 125, 192],
  "darkCore": true,
  "width": 25,
  "textureType": CHUNKY,
  "textureScrollSpeed": 292,
  "pixelsPerTexel": 5,
  "fireSoundOne": "hs_polaris_start",
  "fireSoundTwo": "hs_polaris_shot"
}
[close]

What causes it to do a NullPointerException?
« Last Edit: June 27, 2021, 05:53:29 AM by NinjaSiren »
Logged

Yunru

  • Admiral
  • *****
  • Posts: 927
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7633 on: June 27, 2021, 06:24:06 AM »

Quote
"textureType": CHUNKY,
Isn't vanilla (according to the wiki anyhow), and if you're going for your own custom one, I think it'll need the file extension too?

NinjaSiren

  • Ensign
  • *
  • Posts: 45
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7634 on: June 27, 2021, 06:33:03 AM »

Quote
"textureType": CHUNKY,
Isn't vanilla (according to the wiki anyhow), and if you're going for your own custom one, I think it'll need the file extension too?

Yes, I am only using vanilla, I don't know why it does not work.

UPDATE: I think this is an audio problem, I think I forgot to code the definitions for the new weapon's sound.  :-[  ;D

TY  ;)
« Last Edit: June 27, 2021, 06:46:28 AM by NinjaSiren »
Logged
Pages: 1 ... 507 508 [509] 510 511 ... 532