Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 568 569 [570] 571 572 ... 710

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

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8535 on: February 26, 2022, 10:09:17 AM »

What influences derelict drop rates?

I can have 1 mod with 20 ships and 1 mod with 5 ships.

And the 1 mod with 5 ships will spawn derelict more in sectorgen.. what am I missing? The value? The default_ship_roles.json? I'm kinda confused what directly affects it so much.

Alternatively is there a way for me to exclude certain ships from derelict drops for SectorGen then?

cptdash

  • Ensign
  • *
  • Posts: 32
  • aka SpeedRacer
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8536 on: February 26, 2022, 08:45:54 PM »

I am trying to remove the original DeliveryBarEventCreator instance (as I have created several of my own). In my BaseModPlugin, I am attempting to view/remove the instance of DeliveryBarEventCreator.class from the BarEventManager:


Quote
if (barEventManager.hasEventCreator(DeliveryBarEventCreator.class))
            {
                log("present:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));     //this shows true, meaning it found it
                int i = barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class);     
                log("index:"+barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class)); //this returns -1, meaning it isn't present
                boolean successRemove = barEventManager.getCreators().remove(DeliveryBarEventCreator.class); //this returns false, meaning it wasn't removed
                barEventManager.getCreators().remove(i); //this crashes the game since it tries to remove an item at index -1
                log("present2:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));
            }

Any thoughts on how to go about this?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8537 on: February 27, 2022, 10:46:38 AM »

What influences derelict drop rates?

I can have 1 mod with 20 ships and 1 mod with 5 ships.

And the 1 mod with 5 ships will spawn derelict more in sectorgen.. what am I missing? The value? The default_ship_roles.json? I'm kinda confused what directly affects it so much.

Alternatively is there a way for me to exclude certain ships from derelict drops for SectorGen then?

See: BaseThemeGenerator.addDerelictShip()

Basically derelicts will be picked from the ships of the factions that have a presence nearby, and from a set of default factions otherwise.

Re: excluding certain ships, I don't think so, offhand.

I am trying to remove the original DeliveryBarEventCreator instance (as I have created several of my own). In my BaseModPlugin, I am attempting to view/remove the instance of DeliveryBarEventCreator.class from the BarEventManager:


Quote
if (barEventManager.hasEventCreator(DeliveryBarEventCreator.class))
            {
                log("present:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));     //this shows true, meaning it found it
                int i = barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class);     
                log("index:"+barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class)); //this returns -1, meaning it isn't present
                boolean successRemove = barEventManager.getCreators().remove(DeliveryBarEventCreator.class); //this returns false, meaning it wasn't removed
                barEventManager.getCreators().remove(i); //this crashes the game since it tries to remove an item at index -1
                log("present2:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));
            }

Any thoughts on how to go about this?

The list returned by getCreators() doesn't contain objects of type Class. Rather, it contains instances of the various bar event creators. So you want to iterate over that list and check whether each element is "instanceof DeliveryBarEventCreator" to find the one you're looking for.
Logged

KPMkiller

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8538 on: February 27, 2022, 02:11:30 PM »

Is there any way to change the values that gamma/beta/alpha AI cores give to the industries they are attached to? I am no modder, but I have poked my head with Notepad++ everywhere but java files to no avail; the closest I seen them change/be different was as part of a Colonies related mod.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8539 on: February 27, 2022, 06:46:35 PM »

The script for each industry specifies the effects of AI cores on it. So, yes, you have to get into java coding to modify that.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8540 on: February 28, 2022, 03:44:37 AM »

(Also note that such modification would be mutually exclusive with the likes of Industrial Evolution unless you get really complicated to make it compatible.)

spaceman256

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8541 on: February 28, 2022, 05:55:42 AM »

Hello, I am relatively new to modding. I want to add the special colony items to a supply cache, but it doesn't work.
My code:

SectorEntityToken special_sc1 = system.addCustomEntity("specialcache1",
          "Special Supply Cache",
          "supply_cache",
          null);
   special_sc1.setCircularOrbitPointingDown(gaia9planet, 280, 300, 365);
CargoAPI specialsc1salvage = Global.getFactory().createCargo(true);
   specialsc1salvage.addCommodity(Commodities.GAMMA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.BETA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.ALPHA_CORE, 2);
   BaseSalvageSpecial.addExtraSalvage(specialsc1salvage, special_sc1.getMemoryWithoutUpdate(), -1);

The supply cache and ai cores will spawn as intended, however trying to add special colony items will always crash the game. What do I need to import and what should the code be?
Logged

cptdash

  • Ensign
  • *
  • Posts: 32
  • aka SpeedRacer
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8542 on: February 28, 2022, 10:17:37 AM »


I am trying to remove the original DeliveryBarEventCreator instance (as I have created several of my own). In my BaseModPlugin, I am attempting to view/remove the instance of DeliveryBarEventCreator.class from the BarEventManager:


Quote
if (barEventManager.hasEventCreator(DeliveryBarEventCreator.class))
            {
                log("present:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));     //this shows true, meaning it found it
                int i = barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class);     
                log("index:"+barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class)); //this returns -1, meaning it isn't present
                boolean successRemove = barEventManager.getCreators().remove(DeliveryBarEventCreator.class); //this returns false, meaning it wasn't removed
                barEventManager.getCreators().remove(i); //this crashes the game since it tries to remove an item at index -1
                log("present2:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));
            }

The list returned by getCreators() doesn't contain objects of type Class. Rather, it contains instances of the various bar event creators. So you want to iterate over that list and check whether each element is "instanceof DeliveryBarEventCreator" to find the one you're looking for.

I appreciate the quick responses! I tried your recommendation, which doesn't give any errors but still doesn't seem to remove the mission type. I am doing this inside the onGameLoad() method of BaseModPlugin, maybe that is occurring before all the bar events are initialized?
Code
            BarEventManager barEventManager = BarEventManager.getInstance();
            Iterator<BarEventManager.GenericBarEventCreator> baritr = barEventManager.getCreators().iterator();
            while (baritr.hasNext())
            {
                BarEventManager.GenericBarEventCreator barevent = baritr.next();
                if (barevent instanceof DeliveryBarEventCreator)
                {
                    baritr.remove();
                }
            }
« Last Edit: February 28, 2022, 11:23:39 AM by cptdash »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8543 on: March 02, 2022, 05:02:38 AM »

Can a ship (specifically a module on a larger ship) be made non-restorable in refit screen?

Hello, I am relatively new to modding. I want to add the special colony items to a supply cache, but it doesn't work.
My code:

SectorEntityToken special_sc1 = system.addCustomEntity("specialcache1",
          "Special Supply Cache",
          "supply_cache",
          null);
   special_sc1.setCircularOrbitPointingDown(gaia9planet, 280, 300, 365);
CargoAPI specialsc1salvage = Global.getFactory().createCargo(true);
   specialsc1salvage.addCommodity(Commodities.GAMMA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.BETA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.ALPHA_CORE, 2);
   BaseSalvageSpecial.addExtraSalvage(specialsc1salvage, special_sc1.getMemoryWithoutUpdate(), -1);

The supply cache and ai cores will spawn as intended, however trying to add special colony items will always crash the game. What do I need to import and what should the code be?
Code: java
specialsc1salvage.addSpecial(new SpecialItemData("id_in_special_items.csv", "parameter"), 1);
For e.g. a synchrotron, it'd be addSpecial(new SpecialItemData("synchrotron", null), 1); I think
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8544 on: March 02, 2022, 05:53:19 AM »

Is there a way to get where a ship's armour grid was just hit from a damageListener? (or any way, for that matter, doesn't have to be in the listener)

I've been trying to make a limited-area armour heal that triggers in response to a high damage hit, but it just doesn't seem possible (with a damageListener) given that the source param is the ship that dealt the damage, not the projectile.

Code
Code
    public static class SDSY_TraumaResponse implements DamageListener {
/*
/ added to a ship by a builtin hullmod's advance()
*/
        @Override
        public void reportDamageApplied(Object source, CombatEntityAPI target, ApplyDamageResultAPI result) {
            log.debug("hit registered");
            if (!(source instanceof DamagingProjectileAPI)) {
                log.debug("what the hell hit me");
                log.debug(source.getClass().getName());
                return;
            }
            log.debug("projectile hit registered");

            ShipAPI ship = (ShipAPI) target;
            ArmorGridAPI grid = ship.getArmorGrid();
            DamagingProjectileAPI sourceProj = (DamagingProjectileAPI) source;

/*
/no idea if below this works, turns out it was never getting used
*/

            if (result.getDamageToPrimaryArmorCell() >= 750f) {
                Vector2f centerCellLoc = sourceProj.getLocation();
                int[] centerCellOngrid = grid.getCellAtLocation(centerCellLoc);
                int cellX = centerCellOngrid[0];
                int cellY = centerCellOngrid[1];
                int amountToHeal = (int) Math.round(result.getDamageToPrimaryArmorCell() * 0.6);
                int[][] cellToHeal = {{cellX, cellY},{amountToHeal}};
                String traumaKey = "trauma_" + ship.getId();
                ship.getCustomData().put(traumaKey, cellToHeal);
            }
        }
    }
[close]

Is there currently any way around this or is it a "not possible at all" kinda thing?
And to turn this into an api request (if it's not doable already) - something like getImpactLoc or getPrimaryArmourCellLoc to return where the damage was applied in engine coords would be v useful in applyDamageResultAPI (or something similar). 

spaceman256

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8545 on: March 02, 2022, 07:32:53 AM »


Code: java
specialsc1salvage.addSpecial(new SpecialItemData("id_in_special_items.csv", "parameter"), 1);
For e.g. a synchrotron, it'd be addSpecial(new SpecialItemData("synchrotron", null), 1); I think

Thank you! Everything works perfectly now.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8546 on: March 03, 2022, 02:17:46 PM »

I'm looking to change a portrait between four variants based on the in-game month, how would I go about doing so, if possible?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8547 on: March 03, 2022, 03:18:50 PM »

Can a ship (specifically a module on a larger ship) be made non-restorable in refit screen?

Aside from "it not having d-mods", I don't believe so. Let me add an "unrestorable" tag to hulls and variants.


Is there a way to get where a ship's armour grid was just hit from a damageListener? (or any way, for that matter, doesn't have to be in the listener)

Hmm, I don't think so, no.

Is there currently any way around this or is it a "not possible at all" kinda thing?
And to turn this into an api request (if it's not doable already) - something like getImpactLoc or getPrimaryArmourCellLoc to return where the damage was applied in engine coords would be v useful in applyDamageResultAPI (or something similar).

You might be able to add a DamageTakenModifier or a HullDamageAboutToBeTakenListener to the target (or to the combat engine); that gets you a point parameter. Which you might save to refer to in the subsequent call to the damage listener.


I'm looking to change a portrait between four variants based on the in-game month, how would I go about doing so, if possible?

Apologies if I'm misunderstanding something, but: an every frame script and PersonAPI.setPortraitSprite()?
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8548 on: March 03, 2022, 03:33:02 PM »

I'm looking to change a portrait between four variants based on the in-game month, how would I go about doing so, if possible?

Apologies if I'm misunderstanding something, but: an every frame script and PersonAPI.setPortraitSprite()?
I was thinking something less intensive, like how production only occurs once a month, but thanks!
(Also I don't know how to check the in-game month.)

shoi

  • Admiral
  • *****
  • Posts: 658
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8549 on: March 03, 2022, 03:39:02 PM »

SectorAPI.   getClock().getMonth()
Logged
Pages: 1 ... 568 569 [570] 571 572 ... 710