Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.96a is out! (05/05/23)

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Anexgohan

Pages: [1] 2 3 4
1
v0.2.7 - - Bug Fix Update relesed

  • Nothing new added.
  • Sound Updates and added new sounds for both fire and hit sounds.
  • bug fixes.
  • Fixed AI not using turrets
  • Back end and GitHub update not relevant for end-user just improves my workflow

2
Hey played with the new version, the pinaka is definitely a lot more balanced now, I gave the Lakshya a try and something I noticed is that the AI doesn't seem to fire them at all, and setting them on autofire with manual control would just waste them on ships instead of fighters.
Thanks for testing this and bringing this to my attention, I'll look into it and fix.
Appreciate your work, gave the achuk and sudarshan a try as well. The achuk's s-turn seems fine and most of the missiles can hit the target, maybe 1 or 2 will fly off to the side. But the sudarshan has a problem of flying circles around the target indefinitely, not sure if this is something to do with the s-turn function. Also achuks work fine when left to AI control, but in simulation I couldn't get the AI to fire the sudarshans unless I link it with say a salamander forcing them to fire together.

Yes its a very wierd issue indeed, im trying to wrap my head around it. Will post a fix.

3
Hey played with the new version, the pinaka is definitely a lot more balanced now, I gave the Lakshya a try and something I noticed is that the AI doesn't seem to fire them at all, and setting them on autofire with manual control would just waste them on ships instead of fighters.
Thanks for testing this and bringing this to my attention, I'll look into it and fix.

4
Modding / Re: [0.95.1a] Anex Weapons v0.2.4 - Hell of a Rail Gun Update
« on: February 27, 2022, 01:21:35 AM »
v0.2.4 - Hell of a Rail Gun Update relesed

  • Parashu Twin Mag Rail - Advanced EM Rail propelled solid tungsten carbide shell. Upto 3 times the raw kinetic impact are inherently more accurate than any ballistic weapon.
  • Sound Updates and added new sounds for both fire and hit sounds.
  • bug fixes.
  • Balance pass to previous weapons
  • Pinaka PD got damage and flak damage reduced, no more "father of all PD ever"
  • Dhwij turret damage and flux cost were reduced by a lot.
Parashu Twin Mag Rail

5
Modding / Re: [0.95.1a] Anex Weapons v0.1.2 - Now with Turrets aswell
« on: February 27, 2022, 01:18:43 AM »
Just started a run with this mod, bought some pinaka pd smart, this pd weapon puts a lot of anti-ship weapons to shame, 1337 burst dps(energy) at a 0.2 ratio is crazy, not to mention the excellent accuracy and turn rate, this thing's kinda like a vulcan cannon with 350 more range, much better accuracy, and even more of a threat to fighters/ships. The ammo reload right now is not holding it back much.

Yes, this will be fixed in v0.2.4

6
reserved for future use.

7
Modding / [0.95.1a] Anex Weapons v0.2.4 - Hell of a Rail Gun Update
« on: February 15, 2022, 05:56:50 AM »
The Mod is in Alpha Development state,
All releases are tested and working in Starsector v0.95.1a


Requirement:
Need balance testers for weapons
Need help writing interesting details for those weapons

What the mod is about:
I felt the need to add Weapons to the game specially Missiles for now and needed to learn how to make mods so here we are.
I have a background in graphics and 3d and being a fan of SS since its start so this is my contribution to the game I love so much other than throwing money at Alex.

What's the vision/lore :
Arjuna Industries started as a subsidiary of the Tri-Tachyon supplying them with low-end materials in the beginning to recent high-tech parts manufacturing, mostly stealth tech, missile weapons design and manufacturing, as the company grew so did its ambitions, strategically acquiring and merging with other smaller manufacturers Arjuna Industries supplied the bulk of Tri-Tachyon weapon components.
The Tri-Tachyon took notice of this situation and they were not comfortable with such a monopoly over weapons manufacture not under their majority control, the uneasy Tri-Tachyon tried to diversify and move past this long and fruitful alliance.

Things did not turn out well for Arjuna Industries as one sanction after another and mostly one client and that too turn hostile, Arjuna Industries nearly lost most of its advantages over its competing rival companies. The final push came when Tri-Tachyon tried to initiate a hostile takeover of Arjuna Industries via its rival company.
Tri-Tachyon would have succeeded if it were not for the large scale disruptions caused by the gate collapse and the following Second AI War against Hegemony, the Tri-Tachyon stranglehold on Arjuna Industries weakened over the years.

Arjuna Industries came into possession of knowledge of a vast and resource-rich region on the outer edges of travelled space with several hyperspace lanes leading up to it, untouched by the domain and its Remnants and far from the influence of the Core Worlds during the scavenging of a defunct observatory at the edge of the sector. All mention of this scavenge was purged and every person involved was either hunted down or promoted within Arjuna Industries.

Arjuna Industries knew what had to be done and in a desperate attempt for survival and over several years began in silence shifting its HQ to a secret location and after that shut all its manufacturing across the known space in an instant, for a long while no one knew where Arjuna Industries disappeared, abandoning all its commitments and service contracts. All its weapons and equipment fell into disarray and state of disrepair, the reputation loss caused Arjuna Industries manufactured equipment to become a joke amongst spacefarers only seemed fit for the lowest of the lowest, the unluckiest of the unlucky.

But recently across the black boards, some independent agents can be seen selling brand new Arjuna Industries marked weapons and on open markets, although finding very few willing to purchase due to its tarnished reputation and general disbelief that it is a genuine new Arjuna Industries product, those who have tried these weapons speak extremely highly of these weapons.

Arjuna Industries trade fleets compose of AI-controlled ships with a single captain and two to three crew who never get off from their ships even for negations, they make trade deals to sell weapons and high tech gear in exchange for common supplies and hardware, money or profits is of no interest to them. The Hegemony recently stopped their AI fleet and challenged them to stand down, in the resulting fight when Arjuna Industries AI fleet lost and was disabled, the entire convoy blew themselves up then be boarded, is this loyalty of their crew or AI influence no one knows. For now, they come from shadows trade their high tech gear for cheap goods and return to vast depths of empty space those who tried following them seem to be taken for a ride system hopping one jump lane to other eventually running out of supplies and backing off in disappointment. No one knows why they come and where they go, everyone who trades with them gets rich.

Only time will tell if Arjuna Industries has made a comeback or some pretender has claimed its name instead.
For now, purchase these weapons keeping in mind the risks involved. And do not try to look for them they do not want to be found.

More missiles why:
Starsector has some very decent weapons but I feel missiles are not given the justice they need, look at the current world around you it is held peacefully with the fear of missiles, not tanks, not infantry and not guns. So it's strange to me that missiles in SS are not the same mayhem causing fear-inducing war machines that they really are in a future where armoured ships are flying and not just cylindrical tin cans.

Balance:
Balance is an ongoing process I the mod maker will always be biased to my creations, so I need your help in bringing sanity to my insanity, test it for me and report back either here or discord, if on discord please tag @Anexgohan

The Weapons of Arjuna Industries:

Missiles :
Spoiler
Achuk Missile -
Slow Firing and tracking Barrage that pack a punch both on hull and shields.
Racking and loading missiles with animation.
Sudarshan Missile - Slow Firing and tracking Barrage that eats shields and EMP's the target on hitting Hull does no damage.
Vajra Missile - good tracking fast Barrage that disables target engines does no damage.
Bhairav Torpedoe Launcher - Long-range slow torpedo with barrel animation. Armoured front for PD protection and extra penetration.
Lakshay Anti-Fighter Missile - Medium range low-speed tracking swarm missile built for anti-fighter operations.
Trishul Torpedo to the arsenal - Hybrid torpedo with limited targeting but huge punch and has a chance to bypass shields.
Achuk, Sudarshan & Vajra - Together they make a deadly package, can bring to kneel even the heaviest of targets.
[close]

Turrets:
Spoiler
Pinaka PD smart -
Flak turret with dual barrels and unprecedented rate of fire.
High DPS homing flak shells that mimic actual CIWS in sound and feel.
Dhwij Dual Cannon - Slow Firing Main turret with extremely light target lock.
No burst but decent per shot damage.
Parashu Twin Mag Rail - Advanced EM Rail propelled solid tungsten carbide shell.
Upto 3 times the raw kinetic impact are inherently more accurate than any ballistic weapon.

[close]

Spoiler
More to follow
[close]

Thankyou Note:
  • First off this very forum
  • Everyone over at Starsector Discord who helped specially AxleMC131, wisp, Histidine, Tartiflette for helping me out with most stuff.
  • Special thankyou to Nia Tahl, Harmful Mechanic, ruddygreat and "PureTilt, Freelance Vtuber Waifu" for tolerating my noobie ass and pestering them with thousand questions.
  • Various modders whose script I salvaged, credits are commented in the respective files.
  • If I forgot to mention anyone please let me know and I'm grateful towards you aswell.

Note: These are somewhat OP weapons at the present until balance pass happens. Which will come later down the line.

Changelogs:
Spoiler
v0.2.3 Pre-release - The BCBC adventures
Thanks to BCBC on discord @bcbc , all weapons now have awsome lore related flavour text, feast your eyes at some professional writing
Dwij Turret added - Slow Firing Main turret.
Pinaka PD smart - Flak turret with dual barrels and unprecedented rate of fire. High DPS homing flak shells that mimic actual CIWS in sound and feel.
Sound Updates and added new sounds for both fire and hit sounds
bug fixes, so many bug fixes
now includes a bit of heightmap trickery I learned in photoshop to make sprites appear 3d, first pass will polish more


v0.2.0 Pre-release - Not save Compatible with v01.2a and below, apologies but it was necessary.

Added new sprites for all weapons
Added Trishul Torpedo to the arsenal - Hybrid torpedo with limited targeting but huge punch and has a chance to bypass shields
Fixed scaling issues on every weapon
Standardised the resolution and size of sprites, both for better visuals and functionality.
Added more lore to the faction to read on the forums, hope you like it.
Added new sounds and effects to some missiles

v0.1.2a Pre-release
Fixed crashes caused by a formatting error

v0.1.2
Lakshay Anti-Fighter Missile added, Medium range low-speed tracking swarm missile built for anti-fighter operations
Fixed scaling issues
Added a few new sounds
Increased variety of launch and hit sounds and randomization
reduced screen effects for low-end machines

v0.1.1a Pre-release
Bhairav Missile added
Long rang slow torpedo with barrel animation
did some balancing on other missiles reduced DPS and fire rate

v0.1.1
Fixed launch bug

v0.1.0
First Release
3 Missiles added
Achuk, Vajra & Sudarshan
[close]


My work here is mostly sprite making while most of the actual code is provided by other modders, the intent here is to learn by doing and I have permissions/understandings with the related modders, also, if you go to the java files they are credited there as well.

8
Modding / Re: [WIP] Public Companies - work in progress
« on: February 06, 2022, 12:35:55 AM »
How does one go about listing his company on your publicly traded stock exchange?  ;D

9
Modding / Re: The Radioactive Code Dump
« on: February 06, 2022, 12:33:56 AM »
Yet another missile AI, this time with all the knobs and switches you need to customize it anyway you want. No Java skill needed, but it require to be compiled.
Customizable features:
  • ECCM dependent target leading.
  • Different target selection priorities.
  • Option to reengage a new target when the current one got killed.
  • Controllable vanilla-like waving.
  • Oversteering behavior that tries to orient the velocity toward the leading point instead of just pointing the missile at it.
Tested on a hundred missiles at once with no noticeable performance impact.

Spoiler
Code: Java
//By Tartiflette, highly customizable Missile AI.
package data.scripts.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.GuidedMissileAI;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.lazywizard.lazylib.CollectionUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;

public class CustomMissileAI implements MissileAIPlugin, GuidedMissileAI {
         
   
    //////////////////////
    //     SETTINGS     //
    //////////////////////
   
    //Angle with the target beyond which the missile turn around without accelerating. Avoid endless circling.
    //  Set to a negative value to disable
    private final float OVERSHOT_ANGLE=60;
   
    //Time to complete a wave in seconds.
    private final float WAVE_TIME=2;
   
    //Angle of the waving in degree (divided by 3 with ECCM). Set to a negative value to avoid all waving.
    private final float WAVE_AMPLITUDE=15;
   
    //Damping of the turn speed when closing on the desired aim. The smaller the snappier.
    private final float DAMPING=0.1f;
   
    //Does the missile try to correct it's velocity vector as fast as possible or just point to the desired direction and drift a bit?
    //  Can create strange results with large waving
    //  Require a projectile with a decent turn rate and around twice that in turn acceleration compared to their top speed
    //  Useful for slow torpedoes with low forward acceleration, or ultra precise anti-fighter missiles.     
    private final boolean OVERSTEER=false;  //REQUIRE NO OVERSHOOT ANGLE!
   
    //Does the missile switch its target if it has been destroyed?
    private final boolean TARGET_SWITCH=true;
   
    //Does the missile find a random target or aways tries to hit the ship's one?     
    //   0: No random target seeking,
    //       If the launching ship has a valid target, the missile will pursue that one.
    //       If there is no target selected, it will check for an unselected cursor target.
    //       If there is none, it will pursue its closest valid threat.   
    //   1: Local random target,
    //       If the ship has a target selected, the missile will pick a random valid threat around that one.
    //       If the ship has none, the missile will pursue a random valid threat around the cursor, or itself in AI control.   
    //   2: Full random,
    //       The missile will always seek a random valid threat around itself.
    private final Integer RANDOM_TARGET=0;
   
    //Both targeting behavior can be false for a missile that always get the ship's target or the closest one
    //Prioritize hitting fighters and drones (if false, the missile will still be able to target fighters but not drones)
    private final boolean ANTI_FIGHTER=false;    //INCOMPATIBLE WITH ASSAULT
   
    //Target the biggest threats first
    private final boolean ASSAULT=true;  //INCOMPATIBLE WITH ANTI-FIGHTER
   
    //range in which the missile seek a target in game units.
    private final float MAX_SEARCH_RANGE = 1500;
   
    //range under which the missile start to get progressively more precise in game units.
    private float PRECISION_RANGE=500;
   
    //Is the missile lead the target or tailchase it?
    private final boolean LEADING=true;
   
    //Leading loss without ECCM hullmod. The higher, the less accurate the leading calculation will be.
    //   1: perfect leading with and without ECCM
    //   2: half precision without ECCM
    //   3: a third as precise without ECCM. Default
    //   4, 5, 6 etc : 1/4th, 1/5th, 1/6th etc precision.
    private float ECCM=3;   //A VALUE BELOW 1 WILL PREVENT THE MISSILE FROM EVER HITTING ITS TARGET!
   
   
    //////////////////////
    //    VARIABLES     //
    //////////////////////
   
    //max speed of the missile after modifiers.
    private final float MAX_SPEED;
    //Max range of the missile after modifiers.
    private final float MAX_RANGE;
    //Random starting offset for the waving.
    private final float OFFSET;
    private CombatEngineAPI engine;
    private final MissileAPI MISSILE;
    private CombatEntityAPI target;
    private Vector2f lead = new Vector2f();
    private boolean launch=true;
    private float timer=0, check=0f;

    //////////////////////
    //  DATA COLLECTING //
    //////////////////////
   
    public CustomMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        this.MISSILE = missile;
        MAX_SPEED = missile.getMaxSpeed();
        MAX_RANGE = missile.getWeapon().getRange();
        if (missile.getSource().getVariant().getHullMods().contains("eccm")){
            ECCM=1;
        }       
        //calculate the precision range factor
        PRECISION_RANGE=(float)Math.pow((2*PRECISION_RANGE),2);
        OFFSET=(float)(Math.random()*Math.PI*2);
    }
   
    //////////////////////
    //   MAIN AI LOOP   //
    //////////////////////
   
    @Override
    public void advance(float amount) {
       
        if (engine != Global.getCombatEngine()) {
            this.engine = Global.getCombatEngine();
        }
       
        //skip the AI if the game is paused, the missile is engineless or fading
        if (Global.getCombatEngine().isPaused() || MISSILE.isFading() || MISSILE.isFizzling()) {return;}
       
        //assigning a target if there is none or it got destroyed
        if (target == null
                || target.getOwner()==MISSILE.getOwner()
                || (TARGET_SWITCH && (target instanceof ShipAPI && ((ShipAPI) target).isHulk())
                                  || !engine.isEntityInPlay(target)
                   )
                ){
            setTarget(assignTarget(MISSILE));
            //forced acceleration by default
            MISSILE.giveCommand(ShipCommand.ACCELERATE);
            return;
        }
       
        timer+=amount;
        //finding lead point to aim to       
        if(launch || timer>=check){
            launch=false;
            timer -=check;
            //set the next check time
            check = Math.min(
                    0.25f,
                    Math.max(
                            0.03f,
                            MathUtils.getDistanceSquared(MISSILE, target)/PRECISION_RANGE)
            );
            if(LEADING){
                //best intercepting point
                lead = AIUtils.getBestInterceptPoint(
                        MISSILE.getLocation(),
                        MAX_SPEED*ECCM, //if eccm is intalled the point is accurate, otherwise it's placed closer to the target (almost tailchasing)
                        target.getLocation(),
                        target.getVelocity()
                );               
                //null pointer protection
                if (lead == null) {
                    lead = target.getLocation();
                }
            } else {
                lead = target.getLocation();
            }
        }
       
        //best velocity vector angle for interception
        float correctAngle = VectorUtils.getAngle(
                        MISSILE.getLocation(),
                        lead
                );
       
        if (OVERSTEER){
            //velocity angle correction
            float offCourseAngle = MathUtils.getShortestRotation(
                    VectorUtils.getFacing(MISSILE.getVelocity()),
                    correctAngle
                    );

            float correction = MathUtils.getShortestRotation(               
                    correctAngle,
                    VectorUtils.getFacing(MISSILE.getVelocity())+180
                    )
                    * 0.5f * //oversteer
                    (float)((Math.sin(Math.PI/90*(Math.min(Math.abs(offCourseAngle),45))))); //damping when the correction isn't important

            //modified optimal facing to correct the velocity vector angle as soon as possible
            correctAngle = correctAngle+correction;
        }
       
        if(WAVE_AMPLITUDE>0){           
            //waving
            float multiplier=1;
            if(ECCM<=1){
                multiplier=0.3f;
            }
            correctAngle+=multiplier*WAVE_AMPLITUDE*check*Math.cos(OFFSET+MISSILE.getElapsed()*(2*Math.PI/WAVE_TIME));
        }
       
        //target angle for interception       
        float aimAngle = MathUtils.getShortestRotation( MISSILE.getFacing(), correctAngle);
       
        if(OVERSHOT_ANGLE<=0 || Math.abs(aimAngle)<OVERSHOT_ANGLE){
            MISSILE.giveCommand(ShipCommand.ACCELERATE); 
        }
       
        if (aimAngle < 0) {
            MISSILE.giveCommand(ShipCommand.TURN_RIGHT);
        } else {
            MISSILE.giveCommand(ShipCommand.TURN_LEFT);
        } 
       
        // Damp angular velocity if the missile aim is getting close to the targeted angle
        if (Math.abs(aimAngle) < Math.abs(MISSILE.getAngularVelocity()) * DAMPING) {
            MISSILE.setAngularVelocity(aimAngle / DAMPING);
        }
    }
   
    //////////////////////
    //    TARGETING     //
    //////////////////////
   
    public CombatEntityAPI assignTarget(MissileAPI missile){
       
        ShipAPI theTarget=null;       
        ShipAPI source = missile.getSource();       
        ShipAPI currentTarget;
       
        //check for a target from its source
        if(source != null
                && source.getShipTarget() != null
                && source.getShipTarget() instanceof ShipAPI
                && source.getShipTarget().getOwner() != missile.getOwner()
                ){
            currentTarget=source.getShipTarget();
        } else {
            currentTarget=null;
        }
       
        //random target selection
        if (RANDOM_TARGET>0){ 
            //random mode 1: the missile will look for a target around itsef
            Vector2f location = missile.getLocation();   
            //random mode 2: if its source has a target selected, it will look for random one around that point
            if( RANDOM_TARGET<2){                                     
                if(currentTarget != null
                        && currentTarget.isAlive()
                        && MathUtils.isWithinRange(missile, currentTarget, MAX_RANGE)
                        ){
                    location = currentTarget.getLocation();
                } else if (source != null
                        && source.getMouseTarget()!=null){
                    location=source.getMouseTarget();
                }
            }
            //fetch the right kind of target
            if(ANTI_FIGHTER){
                theTarget = getRandomFighterTarget(location);
            } else if(ASSAULT){
                theTarget = getRandomLargeTarget(location);
            } else {
                theTarget = getAnyTarget(location);
            }   
        //non random targeting   
        } else {
            if(source!=null){
                //ship target first
                if(currentTarget!=null
                        && currentTarget.isAlive()
                        && currentTarget.getOwner()!=missile.getOwner()
                        && !(ANTI_FIGHTER && !(currentTarget.isDrone() && currentTarget.isFighter()))
                        && !(ASSAULT && (currentTarget.isDrone() || currentTarget.isFighter()))
                        ){
                    theTarget=currentTarget;               
                } else {
                    //or cursor target if there isn't one
                    List<ShipAPI> mouseTargets = CombatUtils.getShipsWithinRange(source.getMouseTarget(), 100f);
                    if (!mouseTargets.isEmpty()) {
                        Collections.sort(mouseTargets, new CollectionUtils.SortEntitiesByDistance(source.getMouseTarget()));
                        for (ShipAPI tmp : mouseTargets) {
                            if (tmp.isAlive()
                                    && tmp.getOwner() != missile.getOwner()
                                    && !(ANTI_FIGHTER && !(tmp.isDrone() && tmp.isFighter()))
                                    && !(ASSAULT && (tmp.isDrone() || tmp.isFighter() || tmp.isFrigate()))
                                    ) {
                                theTarget=tmp;
                                break;
                            }
                        }
                    }               
                }
            }
            //still no valid target? lets try the closest one
            //most of the time a ship will have a target so that doesn't need to be perfect.
            if(theTarget==null){
                List<ShipAPI> closeTargets = AIUtils.getNearbyEnemies(missile, MAX_SEARCH_RANGE);
                if (!closeTargets.isEmpty()) {
                    Collections.sort(closeTargets, new CollectionUtils.SortEntitiesByDistance(missile.getLocation()));
                    if (ASSAULT){   //assault missiles will somewhat prioritize toward bigger threats even if there is a closer small one, and avoid fighters and drones.
                        for (ShipAPI tmp : closeTargets) {
                            if (tmp.isAlive()
                                    && tmp.getOwner() != missile.getOwner()
                                    ) {
                                if (tmp.isCapital() || tmp.isCruiser()){
                                    theTarget=tmp;
                                    break;
                                } else if (tmp.isDestroyer() && Math.random()>0.5){
                                    theTarget=tmp;
                                    break;
                                } else if (tmp.isDestroyer() && Math.random()>0.75){
                                    theTarget=tmp;
                                    break;
                                } else if (!tmp.isDrone() && !tmp.isFighter() && Math.random()>0.95){
                                    theTarget=tmp;
                                    break;
                                }
                            }
                        }
                    }else if(ANTI_FIGHTER){    //anti-fighter missile will target the closest drone or fighter
                        for (ShipAPI tmp : closeTargets) {
                            if (tmp.isAlive()
                                    && tmp.getOwner() != missile.getOwner()
                                    && (tmp.isDrone() || tmp.isFighter())
                                    ) {
                                theTarget=tmp;
                                break;
                            }
                        }
                    }else{  //non assault, non anti-fighter missile target the closest non-drone ship
                        for (ShipAPI tmp : closeTargets) {
                            if (tmp.isAlive()
                                    && tmp.getOwner() != missile.getOwner()
                                    && !tmp.isDrone()
                                    ) { 
                                theTarget=tmp;
                                break;
                            }
                        }
                    }
                }
            }
        }       
        return theTarget;
    }
   
    //Random picker for fighters and drones
    public ShipAPI getRandomFighterTarget(Vector2f location){
        ShipAPI select=null;
        Map<Integer, ShipAPI> PRIORITYLIST = new HashMap<>();
        Map<Integer, ShipAPI> OTHERSLIST = new HashMap<>();
        int i=1, u=1;
        List<ShipAPI> potentialTargets = CombatUtils.getShipsWithinRange(location, MAX_RANGE);
        if (!potentialTargets.isEmpty()) {
            for (ShipAPI tmp : potentialTargets) {
                if (tmp.isAlive()
                        && tmp.getOwner() != MISSILE.getOwner()
                        ) {
                    if (tmp.isFighter() || tmp.isDrone()){
                        PRIORITYLIST.put(i, tmp);
                        i++;
                    } else {                           
                        OTHERSLIST.put(u, tmp);
                        u++;
                    }
                }
            }
            if (!PRIORITYLIST.isEmpty()){
                int chooser=Math.round((float)Math.random()*(i-1)+0.5f);
                select=PRIORITYLIST.get(chooser);
            } else if (!OTHERSLIST.isEmpty()){                   
                int chooser=Math.round((float)Math.random()*(u-1)+0.5f);
                select=OTHERSLIST.get(chooser);
            }
        }
        return select;
    }
   
    //Random target selection strongly weighted toward bigger threats in range
    public ShipAPI getRandomLargeTarget(Vector2f location){
        ShipAPI select=null;
        Map<Integer, ShipAPI> PRIORITY1 = new HashMap<>();
        Map<Integer, ShipAPI> PRIORITY2 = new HashMap<>();
        Map<Integer, ShipAPI> PRIORITY3 = new HashMap<>();
        Map<Integer, ShipAPI> PRIORITY4 = new HashMap<>();
        Map<Integer, ShipAPI> OTHERSLIST = new HashMap<>();
        int i=1, u=1, v=1, x=1, y=1;
        List<ShipAPI> potentialTargets = CombatUtils.getShipsWithinRange(location, MAX_RANGE);
        if (!potentialTargets.isEmpty()) {
            for (ShipAPI tmp : potentialTargets) {
                if (tmp.isAlive()
                        && tmp.getOwner() != MISSILE.getOwner()
                        && !tmp.isDrone()
                        ) {
                    if (tmp.isCapital()){
                        PRIORITY1.put(i, tmp);
                        i++;
                        PRIORITY2.put(u, tmp);
                        u++;
                        PRIORITY3.put(x, tmp);
                        x++;
                        PRIORITY4.put(v, tmp);
                        v++;
                        OTHERSLIST.put(y, tmp);
                        y++;
                    } else if (tmp.isCruiser()){
                        PRIORITY2.put(u, tmp);
                        u++;
                        PRIORITY3.put(x, tmp);
                        x++;
                        PRIORITY4.put(v, tmp);
                        v++;
                        OTHERSLIST.put(y, tmp);
                        y++;
                    } else if (tmp.isDestroyer()){
                        PRIORITY3.put(x, tmp);
                        x++;
                        PRIORITY4.put(v, tmp);
                        v++;
                        OTHERSLIST.put(y, tmp);
                        y++;
                    } else if (tmp.isFrigate()){
                        PRIORITY4.put(v, tmp);
                        v++;
                        OTHERSLIST.put(y, tmp);
                        y++;
                    } else {
                        OTHERSLIST.put(y, tmp);
                        y++;
                    }
                }
            }
            if (!PRIORITY1.isEmpty() && Math.random()>0.8f){
                int chooser=Math.round((float)Math.random()*(i-1)+0.5f);
                select=PRIORITY1.get(chooser);
            } else if (!PRIORITY2.isEmpty() && Math.random()>0.8f){
                int chooser=Math.round((float)Math.random()*(u-1)+0.5f);
                select=PRIORITY2.get(chooser);
            } else if (!PRIORITY3.isEmpty() && Math.random()>0.8f){
                int chooser=Math.round((float)Math.random()*(x-1)+0.5f);
                select=PRIORITY3.get(chooser);
            } else if (!PRIORITY4.isEmpty() && Math.random()>0.8f){
                int chooser=Math.round((float)Math.random()*(v-1)+0.5f);
                select=PRIORITY4.get(chooser);
            } else if (!OTHERSLIST.isEmpty()){                   
                int chooser=Math.round((float)Math.random()*(y-1)+0.5f);
                select=OTHERSLIST.get(chooser);
            }
        }
        return select;
    }

    //Pure random target picker
    public ShipAPI getAnyTarget(Vector2f location){
        ShipAPI select=null;
        Map<Integer, ShipAPI> TARGETLIST = new HashMap<>();
        int i=1;
        List<ShipAPI> potentialTargets = CombatUtils.getShipsWithinRange(location, MAX_RANGE);
        if (!potentialTargets.isEmpty()) {
            for (ShipAPI tmp : potentialTargets) {
                if (tmp.isAlive()
                        && tmp.getOwner() != MISSILE.getOwner()
                        && !tmp.isDrone()
                        ){
                    TARGETLIST.put(i, tmp);
                    i++;                       
                }
            }
            if (!TARGETLIST.isEmpty()){
                int chooser=Math.round((float)Math.random()*(i-1)+0.5f);
                select=TARGETLIST.get(chooser);
            }
        }
        return select;
    }
   
    @Override
    public CombatEntityAPI getTarget() {
        return target;
    }

    @Override
    public void setTarget(CombatEntityAPI target) {
        this.target = target;
    }
   
    public void init(CombatEngineAPI engine) {}
}
[close]

Hey, everyone,
I was looking at your forum post here

I'm making some missiles for the game and would love to implement this for my missiles, sadly I have zero coding background could you give me any pointers if it's possible for someone like me to implement this as you said "no java skills needed"
thankyou for reading

10
Modding Resources / Re: [0.8.1a] STARSECTOR Ship&Weapon Editor (v2.7.4)
« on: February 04, 2022, 06:44:43 PM »
Any help for finding Help on Weapons making specifically Missiles would be very helpful for me and those looking for some help. Any helpful person please help out with some help on finding help to help making weapons.

Thanaks for any help

11
Mods / Re: [0.8.1a] The Knights Templar 0.9.8f
« on: February 04, 2022, 02:49:32 PM »
So, im just posting here hoping that this mod gets updated, I have so many Nightmarish memories of this mod and its OP faction, hope to see it back in action some day.

Also, I know by posting this I have made the to be release day counter go up. :p

12
Mods / Re: [0.95.1a] Nexerelin v0.10.4b "Dissonance" (hotfix 2022-01-30)
« on: February 04, 2022, 12:44:42 PM »
Hello,
Is there any way to move my already existing Prism Freeport from Hyperspace to one inside a System, cause the hyperspace lag is killing my months long playthrough.

I managed to delete my already existing Prism from hyper space
using this code:
Code
runcode MarketAPI market = Global.getSector().getEconomy().getMarket("nex_prismFreeport");
Global.getSector().getEconomy().removeMarket(market);
market.getPrimaryEntity().getContainingLocation().removeEntity(market.getPrimaryEntity());

and i can create a new one using this code:
Code
runcode new exerelin.world.ExerelinNewGameSetup().addPrismMarket(Global.getSector(), false);


but the issue is its generating the Prism port in the exact same location in Hyperspace and not in its own System,
Anyone can help me out please


Thanks for this awesome mod.

13
Mods / Re: [0.95.1a] Junk Yard Dogs - V 1.55a - 01/31/22
« on: February 03, 2022, 01:37:03 AM »
Dude, I love your mod honestly, I don't care if its balanced or not or the graphics are version 0.32, the most fun I had just going pew pew, thanks for the mod.

14
Can you please, point me to what you did, yours is a better solution than what I posted. Atleast then I could use the training building.

15
Mods / Re: [0.95.1a] Ship/Weapon Pack 1.13.0
« on: February 01, 2022, 12:28:43 AM »
Any way to remove the "Extreme Modifications" mod I by mistake added it to my flagship and now its stuck with it ?

Pages: [1] 2 3 4