Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 312 313 [314] 315 316 ... 474

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17509
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4695 on: July 11, 2019, 08:30:41 AM »

For this one, it's actually just data, no code needed.

In salvage_entity_gen_data.csv, there's a "stationRole"column. For the mothership, it says "derelictMothership".

In derelict.faction, we've got:
"shipRoles":{
   "derelictMothership":{
      "station_derelict_survey_mothership_Standard":10,
   },
},

And that's it.

If you wanted to do something fancier, you could use a SalvageDefenderModificationPlugin (see: SalvageGenFromSeed). This is, for example, how the game handles increasing derelict defense strengths, and a couple of other special defenders (red planet, cryosleeper).
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 586
  • -- D O C T O R --
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4697 on: July 12, 2019, 08:02:35 PM »

Another question, except this time a bit more involved;

This is a script I used to give my GMDA ships a boost to stats above a certain flux threshold and when the ship is not overloaded. This is based off a script that Histidine wrote for me ages ago that I've since adapted. The code worked in 0.9, however as of 0.9.1a it no longer works, and I can't determine why. The only clue I have is the fact that the compiler required the String id section at the front to compile correctly, and since then the code doesn't work. I feel I'm overlooking something basic, but I lack the know-how to interpret. Could anyone lend me a hand please?
Spoiler
Code
    public void advanceInCombat(ShipAPI ship, String id) {
        if (ship.getFluxTracker().getFluxLevel() >= 0.65 && !ship.getFluxTracker().isOverloaded()){
            Global.getCombatEngine().maintainStatusForPlayerShip(SPEEDKEY, "graphics/icons/hullsys/temporal_shell.png",
                    "Bludknock Overdrive System Active",
                    "Increased Speed and Venting!",
                    false);
            ship.getMutableStats().getMaxSpeed().modifyMult(id, HIGH_SPEED_MOD);
            ship.getMutableStats().getFluxDissipation().modifyMult(id, HIGH_VENT_MOD);
            ship.getMutableStats().getAcceleration().modifyMult(id, HANDLING_MULT);
            ship.getMutableStats().getDeceleration().modifyMult(id, HANDLING_MULT);
            ship.getMutableStats().getMaxTurnRate().modifyMult(id, HANDLING_MULT);
            ship.getMutableStats().getTurnAcceleration().modifyMult(id, HANDLING_MULT);
        }
            if (ship.getFluxTracker().getFluxLevel() >= 0.65 && ship.getFluxTracker().isOverloaded()){
                ship.getMutableStats().getMaxSpeed().unmodifyMult(id);
                ship.getMutableStats().getFluxDissipation().unmodifyMult(id);
                ship.getMutableStats().getAcceleration().unmodifyMult(id);
                ship.getMutableStats().getDeceleration().unmodifyMult(id);
                ship.getMutableStats().getMaxTurnRate().unmodifyMult(id);
                ship.getMutableStats().getTurnAcceleration().unmodifyMult(id);

            }
            if (ship.getFluxTracker().getFluxLevel() < 0.65){
                ship.getMutableStats().getMaxSpeed().unmodifyMult(id);
                ship.getMutableStats().getFluxDissipation().unmodifyMult(id);
                ship.getMutableStats().getAcceleration().unmodifyMult(id);
                ship.getMutableStats().getDeceleration().unmodifyMult(id);
                ship.getMutableStats().getMaxTurnRate().unmodifyMult(id);
                ship.getMutableStats().getTurnAcceleration().unmodifyMult(id);}
    }
[close]

SafariJohn

  • Admiral
  • *****
  • Posts: 1850
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4698 on: July 13, 2019, 09:01:10 AM »

All of the advanceInCombat methods you could override have "ShipAPI ship" and "float amount" as parameters. If your parameters don't match that exactly, the game won't call the method.

The compiler complained at you because it couldn't find where id is declared. The simplest solution is to add a declaration above the first if-statement, like this:

Code
String id = "GMDA_BOSA";

On a side note, you can compress the last two if-statements into:
Code
if (ship.getFluxTracker().isOverloaded() || ship.getFluxTracker().getFluxLevel() < 0.65) {
    ship.getMutableStats().getMaxSpeed().unmodifyMult(id);
    ship.getMutableStats().getFluxDissipation().unmodifyMult(id);
    ship.getMutableStats().getAcceleration().unmodifyMult(id);
    ship.getMutableStats().getDeceleration().unmodifyMult(id);
    ship.getMutableStats().getMaxTurnRate().unmodifyMult(id);
    ship.getMutableStats().getTurnAcceleration().unmodifyMult(id);
}
Logged

Inventor Raccoon

  • Captain
  • ****
  • Posts: 375
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4699 on: July 13, 2019, 01:59:14 PM »

Is it possible to set the name of a ShipAPI or somehow update it to match the FleetMemberAPI?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17509
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4700 on: July 13, 2019, 09:08:36 PM »

Let me add setName() to ShipAPI. Various UI elements might not update when it changes, though, i.e. if you have a target reticle, it'd most likely keep displaying the name-that-was at the time the ship was targeted.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 2878
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4701 on: July 13, 2019, 11:09:26 PM »

If I wanted a fleet created by a RouteFleetSpawner to go straight to its destination instead of chasing down random enemy fleets, how would I do it? Is there a part of RouteFleetAssignmentAI that I should change?

As an aside: Should there be a more reliable way of generating loot drops from killing enemies (e.g. AI cores from Remnants)?
The current method of using an FID config gen override on MyFleet breaks if that config gen isn't called by the fleet interaction dialog plugin for any reason... such as when the player interacts with another fleet and MyFleet is pulled in. This doesn't come up in vanilla and a mod could add its own handling (e.g. with reportEncounterLootGenerated in a listener), but an easier approach would be nice.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17509
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4703 on: July 14, 2019, 07:36:00 AM »

If I wanted a fleet created by a RouteFleetSpawner to go straight to its destination instead of chasing down random enemy fleets, how would I do it? Is there a part of RouteFleetAssignmentAI that I should change?

You'd probably want to override addLocalAssignment, addStartingAssignment, addTravelAssignment, and addEndingAssignment to ... basically do the same thing they're doing, but using one of the DELIVER_* assignments to move them around - which makes a fleet move somewhere and not chase unless the enemy fleet overlaps.

Could also set $isTradeFleet to true in the fleet's memory, but that may have some undesired side effects.

Let me make a note to add another flag that does this w/o flagging it as a trader, since this seems to come up a fair bit.

Edit: you could also call ModularFleetAIAPI.getStrategicModule().getDoNotAttack() and periodically add all nearby fleets to it - either in another script added to the fleet, or in the fleet's assignment AI if it has a custom one already.

As an aside: Should there be a more reliable way of generating loot drops from killing enemies (e.g. AI cores from Remnants)?
The current method of using an FID config gen override on MyFleet breaks if that config gen isn't called by the fleet interaction dialog plugin for any reason... such as when the player interacts with another fleet and MyFleet is pulled in. This doesn't come up in vanilla and a mod could add its own handling (e.g. with reportEncounterLootGenerated in a listener), but an easier approach would be nice.

Let me make a note to take a look at this; good point about the "fleet being pulled in" case.
« Last Edit: July 14, 2019, 08:09:59 AM by Alex »
Logged

tzuridis

  • Ensign
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4704 on: July 16, 2019, 07:39:27 AM »

Random question, mostly on what you guys think would be the best way to go about this. I want to create a mod that changes combat somewhat, basically doing this:

Small ships are faster either by 50%, more or less (using the designations?). As are missiles and torpedoes. Missiles and torpedoes also do 3x - 5x more damage but all weapons can fire 100 - 200% further similar to the hullmod for the battle station. The whole point of this is to make it so that small ships are still capable of taking down big fellas if they can get around as shield strength will be the same. Would test it out a bit, mess around, maybe push the mod so people can try a new experience.

So my idea to implement this was in hope of finding a base hullmod that all ships had, perhaps hidden or something. Not really applicable to apply to all .ship files especially with other mods. I did find the basehullmod in the API, is there one in hullmods that applies to all ships? I was hoping I could find something in there so I could import the supercomputer targetting mod. I'm pretty sure my way is wrong, so any advice as to what should I take a look at? I am guessing it is all in the API?

I don't know java but I know js so I think I could figure it out eventually.
« Last Edit: July 16, 2019, 07:45:10 AM by tzuridis »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17509
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4705 on: July 16, 2019, 07:57:00 AM »

I think you're thinking about this in a good way as far as structuring it, but, yeah - there's no such hullmod.

That being absent, the best way to go is probably an EveryFrameCombatPlugin that keeps track of which ships it's seen so far, and then applies your desired changes to ships right after they get deployed.

See: data.scripts.plugins.TestCombatPlugin for a really messy and extremely random implementation of a combat plugin; it's one I've used to test an assortment of things. If you put it in data.scripts.plugins, you don't need to register it. If you put it elsewhere (say because you've set things up to compile your mod's code into a jar) you'd need to add it to the "plugins" section in settings.json for it to be picked up.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4882
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4706 on: July 16, 2019, 08:25:46 AM »

Here's a basic, bare-bones structure for what Alex said.  I was going to recommend going down the Built-In Hull Mod route, but this will work for testing basic concepts or global effects like this. 

You'll really, really want to install a Java IDE first and learn to make "my first JAR", etc.  See Modding Tools; there are great, newbie-friendly instructions for installing NetBeans, Intellij, etc. here.

Code: java
public class my_awesome_plugin_example implements EveryFrameCombatPlugin {

private CombatEngineAPI engine;

    @Override
    public void init(CombatEngineAPI cEngine) {
engine = cEngine;
    }

    @Override
    public void advance(float amount, List events) {
         //If we're paused or not in combat or whatever, stop here.
         if(engine == null
             || engine.isPaused()
             || (!engine.isInCampaign() && !engine.isInCampaignSim() && !engine.isMission() && !engine.isSimulation())){
                return;
         }   

         //Get all of the ships currently on the battlefield, iterate through them.
         for(ShipAPI ship : engine.getShips()){
                  //Do stuff to ships here, depending on what they are, etc.
         }

    }

    @Override
    public void renderInWorldCoords(ViewportAPI viewport) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void renderInUICoords(ViewportAPI viewport) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

@Override
public void processInputPreCoreControls(float f, List<InputEventAPI> list) {
}

}
Logged
Please check out my SS projects :)
Xeno's Mod Pack

tzuridis

  • Ensign
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4707 on: July 16, 2019, 08:31:16 AM »

Awesome thanks for the quick replies.
Logged

tzuridis

  • Ensign
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4708 on: July 17, 2019, 06:57:04 AM »

2 quick if you guys have time. I am editing the testcombat plugin. I tried to use this method:

Code
public class TestCombatPlugin extends BaseEveryFrameCombatPlugin { 

public static float DAMAGE_MISSILES_PERCENT = 200f;
public static float SPEED_MISSILES_PERCENT = 500f;

public static float SPEED_BONUS = 525f;
public static float TURN_BONUS = 20f;

/**
* Set this to true to have the plugin actually do stuff.
*/
private static boolean TEST_MODE = true;

private CombatEngineAPI engine;
public void init(CombatEngineAPI engine) {
this.engine = engine;
}

   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDamageToMissiles().modifyPercent(id, DAMAGE_MISSILES_PERCENT);
stats.getMaxSpeed().modifyPercent(id, SPEED_BONUS);
stats.getBallisticWeaponRangeBonus().modifyFlat(id, 600f);
stats.getBeamWeaponRangeBonus().modifyFlat(id, 300f);
}
I am not sure how to do this exactly. I see this stems from basehull which I believe is not passed down to baseeveryframecombat plugin? Not really any methods that I can pull from there right?

Could you give me a little more syntax as to how I could write the for loop you gave me below? .getShips doesn't take the parameters right? Could I even use stats.getMaxSpeed() or methods like that. I have stats imported through MutableShipStatsAPI.



 
Code
@Override
    public void advance(float amount, List events) {
         //If we're paused or not in combat or whatever, stop here.
         if(engine == null
             || engine.isPaused()
             || (!engine.isInCampaign() && !engine.isInCampaignSim() && !engine.isMission() && !engine.isSimulation())){
                return;
         }   

         //Get all of the ships currently on the battlefield, iterate through them.
         for(ShipAPI ship : engine.getShips()){
                 
         }

    }

This part is not in the file by the way, only the top part I couldn't figure out the syntax for this part. If I am totally wrong I am to take a fee java course.

Thanks for any help
« Last Edit: July 17, 2019, 06:59:22 AM by tzuridis »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4882
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4709 on: July 17, 2019, 10:02:55 AM »

You're going to want to write something that changes the MutableShipStatsAPI, accessible through ShipAPI (hence why I gave it that way).  Essentially, just tweak their max stats directly through a buff.

The only tricky bit, in terms of performance, is designing it so that it doesn't repeat; this is best-achieved through a HashSet, so that you can check .contains() for the presence of the ShipAPI in question and only alter its stats once.

Sorry if that went whoosh over your head, but basically, in Java, there are traditional data structures like arrays and a bunch of more exotic ones that offer great lookup performance, but are a little more difficult to understand initially.
Logged
Please check out my SS projects :)
Xeno's Mod Pack
Pages: 1 ... 312 313 [314] 315 316 ... 474