Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: Hullmod Request  (Read 3177 times)

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Hullmod Request
« on: May 06, 2017, 01:00:48 PM »

If anyone can help at all. I'm after a couple of hullmods:
*first, One that produces fuel by being in close proximity to a star.   (for a WIP stargate mod. For the destiny)
*second. A hullmod that can produce supplies, either a changeable fixed rate or one that scales depending on distance to a star. For a WIP battlestar mod. A food producing ship.
*also need assistance in adding them to a mod. I've no coding experience other than altering existing ships, weapons, and systems.

Thanks in advance to those that reply.
Logged

gofastskatkat

  • Lieutenant
  • **
  • Posts: 53
    • View Profile
Re: Hullmod Request
« Reply #1 on: May 10, 2017, 10:43:20 AM »

Im not a modder myself, but the Appro-light mod has a frigate that has a hullmod in it that makes the ship produce food. I would ask the dev of that mod to see if you can use it or for tips on how to make your own, though fair warning, he's Chinese (I think) so there may be a language barrier
Logged

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Hullmod Request
« Reply #2 on: May 11, 2017, 04:13:49 AM »

I'll have a look at that tomorrow. Thanks  for letting me know about that one.  :)
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Hullmod Request
« Reply #3 on: May 11, 2017, 04:30:47 AM »

I help you for this two hullmods, maybe on 6hours(I am not in my home, currently).
Contrary when I am come to this forum, now I have experience, so normally, I go not have problem for create your hullmod.

For the implementation, I go talk with you on private message, I think.




Edit: The code: Many boolean for check + Template code than many people use for your request:


PS: can be bugged, but when i have tested, this thing have worked.
Code
package src.data.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;

import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

public class Lt_EnergyConverterFuel extends BaseHullMod {


    protected IntervalUtil tracker = new IntervalUtil(1, 1);

    @Override
    public void advanceInCampaign(FleetMemberAPI member, float amount) {
         SectorAPI sector = Global.getSector();
if (sector.isPaused()) {
return;
}
        if (member.getFleetData().getFleet().isPlayerFleet()) {
            CampaignFleetAPI fleet = sector.getPlayerFleet();
            
            if (!fleet.isInHyperspace()) {

                SectorEntityToken star = fleet.getLightSource();
                Vector2f lightsourceLoc = star.getLocation();
                float radiusstar = star.getRadius();
                Vector2f fleetLoc = new Vector2f(member.getFleetData().getFleet().getLocation());
                float length = new Vector2f(fleetLoc.getX()-lightsourceLoc.getX(),fleetLoc.getY()-lightsourceLoc.getY()).length();
                float range=2000f;
                
        
                if ((length ) < (range+ radiusstar)) {
                    float days = Global.getSector().getClock().convertToDays(amount);
      // a days is : 0.0017 to 0.0020, a amount is 0.017 to 0.020  (frame*(frame per second)=1 second)
                    tracker.advance((days/1000)*((range+ radiusstar)-length));
                    if (!tracker.intervalElapsed()) {
                        return;
                    }

                    if (!member.isMothballed()) {
                         CargoAPI cargo= fleet.getCargo();
                       //if(cargo.getSpaceLeft()>0);     //
                        if(cargo.getFreeFuelSpace()>0){  
                       cargo.addCommodity(Commodities.FUEL, 1); // Commodities.SUPPLIES
                        }
                    }

                }
            }
        }
    }


}



So, this hullmod who work only for player, give fuel when you are near of a source of light. More hullmod you have, more fuel you have. You can also change the range where he begin.

If you are  to 2000 meters of a light source, the hullmod go active. Then, more you go near of the light source, more we increase per frame the energy allocated(    tracker.advance((days/1000)*((range+ radiusstar)-length)); )



Else, yes, more you have a fps, more you win fuel, but meh, this is always like that.

You can change with supplie if you want. But do not forgot the if for check if you have available space.



With this value of   tracker.advance((days/1000)*((range+ radiusstar)-length));
And three ships who have hullmod, i win 1 fuel per second. So you need increase the "1000", but after the float is too low, so just this tracker:

protected IntervalUtil tracker = new IntervalUtil("number to increase", "number to increase");

Maybe 10, or 100, you who choice. You can also put a different value with the size of your ship. But i think you know how.
« Last Edit: May 11, 2017, 11:42:38 AM by Snrasha »
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

joe130794

  • Commander
  • ***
  • Posts: 226
    • View Profile
Re: Hullmod Request
« Reply #4 on: May 12, 2017, 07:48:17 AM »

Thank you very much for the post. I've replied to your message.
Logged