Fractal Softworks Forum

Starsector => Mods => Topic started by: Archigo on July 21, 2018, 03:10:20 AM

Title: [0.97a] Weapon Arcs 1.7.2
Post by: Archigo on July 21, 2018, 03:10:20 AM
This is a simple mod that draws the weapon arcs of all weapons groups on the players ship, in contrast to vanilla which only draws the selected group.

Is it useful? If you use missiles you have likely noticed that there is no way to select the missile group and still see the weapon arcs of your other weapons, which you might want to see for aiming etc. This mod fixes that.

Github (https://github.com/archigo/WeaponArcsStarsector)
Download (https://github.com/archigo/WeaponArcsStarsector/raw/master/WeaponArcs.zip)

Requirements
LazyLib (http://fractalsoftworks.com/forum/index.php?topic=5444.0)

Controls
Use "Left ALT + 1-7" to toggle drawing of weapon groups on/off.
If for some reason using Left ALT does not work, you can change the key from settings.

It is recommended (but not required) to disable vanilla weapon arcs while using this mod. Default hotkey for disabling vanilla is "~".

In the root folder of the mod you will find "weapon-arcs-settings.json". From there you can:


Changelog

1.7.2 - Updated how the control key is checked, removing some weird cases where the key would get stuck. Also made it possible to unbind the ALT key.

1.7.1 - Updated version number for 0.97a-RC6

1.7.0 - Added a config setting for range bands. Default is 4 and it can be set to other amounts. Credit goes to Lrizika for implementing this feature https://github.com/archigo/WeaponArcsStarsector/pull/2

1.6.0 - Added toggle key as workaround for Mac users. Added functionality to have individual colors on each weapon group.

1.5.0 - Added setting to change the "roughness" of the displayed Weapon arcs. Fixed a potential crash.

1.4.1 - Support weapon groups 6 and 7.

1.4.0 - Update game version number. Add additional crash check.

1.3.1 - Fixed possible crash on entering combat

1.3.0 - Introduced in memory caching of active groups, will persist as long as you do not change ship. Introduced settings file in the main folder of the mod. Can set weapon arc colors and set group to auto enable.

1.2.2 - Fixed a case sensitivity issue with version checker files on Linux.

1.2.1 - Updated the download link, so the new version can actually be downloaded! Also implemented version checker support

1.2 - updated mod info for 0.9. Weapon arcs are now off by default simply turn them on with "ALT + 1-5".

1.1 - Introduced the ability to toggle drawing of individual weapon groups off, with "ALT + 1-5".

Compatibility
This mod should be compatible with all other mods. Other mods might use the same hotkeys, but both mods should still work.

Save games
This mod is save game safe. Add it to you existing saves, or remove it, the saves will still work.

In game examples
Spoiler
Vanilla:
(https://raw.githubusercontent.com/archigo/WeaponArcsStarsector/master/ConquestVanilla.jpg)
Mod:
(https://raw.githubusercontent.com/archigo/WeaponArcsStarsector/master/Conquest.jpg)
Vanilla:
(https://raw.githubusercontent.com/archigo/WeaponArcsStarsector/master/DominatorVanilla.jpg)
Mod:
(https://raw.githubusercontent.com/archigo/WeaponArcsStarsector/master/Dominator.jpg)
[close]

Credits
LazyWizard - the creator of Lazylib, which is used for vector rotation in this mod.

Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Archigo on July 21, 2018, 11:22:45 AM
Edit: These issues have been solved - Solution: Compile as jar instead of letting Janino compile on game run.

I've been trying to implement switching weapon groups off, but i hit a snag:

Code
List<WeaponGroupAPI> weaponGroups = engine.getPlayerShip().getWeaponGroupsCopy();
List<WeaponAPI> weapons = weaponGroups.get(0).getWeaponsCopy();

When i run startsector this gives me:
"A method name "getWeaponsCopy" is not declared in any enclosing class nor any supertype, nor through a static import"

The method is right here though: http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/WeaponGroupAPI.html#getWeaponsCopy() and netbeans also find it in the starfarer api file

Any idea why this is?

Additionally i tried using ArrayList for some stuff, but when using methods like "isEmpty()" and "size()" i would get errors as well. Is it not possible to use ArrayLists in a script? If i try to use the "List" type that the api returns i apparently have to implement all the interface methods on it.

full code:
Spoiler
Code
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponGroupAPI;
import org.json.JSONException;
import org.json.JSONObject;
import org.lazywizard.lazylib.FastTrig;
import org.lazywizard.lazylib.JSONUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.opengl.DrawUtils;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector2f;

import java.awt.*;
import java.io.IOException;
import java.util.List;

public class WeaponArcs extends BaseEveryFrameCombatPlugin {
    
    private CombatEngineAPI engine;
    private ShipAPI player;
    private static Color WEAPON_ARC_COLOR;
    private static String[][] DO_NO_DRAW_WEAPONS;
    
    @Override
    public void init(CombatEngineAPI engine) {
        this.engine = engine;
        WEAPON_ARC_COLOR = Global.getSettings().getColor("weaponArcColor");
        if (DO_NO_DRAW_WEAPONS == null) {
            DO_NO_DRAW_WEAPONS = new String[5][40];
        }
    }
    
    public void advance(float amount, List<InputEventAPI> events) {
        
        for (InputEventAPI event : events) {
            if (event.isAltDown() && event.getEventChar() == '1' || event.getEventChar() == '2' || event.getEventChar() == '3' || event.getEventChar() == '4' || event.getEventChar() == '5') {
                int index;
                switch (event.getEventChar()) {
                    case '1':
                        index = 0;
                        if (DO_NO_DRAW_WEAPONS[index].length == 0) {
                            List<WeaponGroupAPI> weaponGroups = engine.getPlayerShip().getWeaponGroupsCopy();
                            List<WeaponAPI> weapons = weaponGroups.get(0).getWeaponsCopy();
                            for (int i = 0; i < weapons.size(); i++) {
                                WeaponAPI weapon = weapons.get(i);
                                DO_NO_DRAW_WEAPONS[index][i] = weapon.getId();
                            }
                        } else {
                            for (int i = 0; i < DO_NO_DRAW_WEAPONS[index].length; i++) {
                                DO_NO_DRAW_WEAPONS[index][i] = null;
                            }
                        }
                        break;
                    case '2':
                        index = 1;
                        if (DO_NO_DRAW_WEAPONS[index].length == 0) {
                            List<WeaponGroupAPI> weaponGroups = engine.getPlayerShip().getWeaponGroupsCopy();
                            List<WeaponAPI> weapons = weaponGroups.get(0).getWeaponsCopy();
                            for (int i = 0; i < weapons.size(); i++) {
                                WeaponAPI weapon = weapons.get(i);
                                DO_NO_DRAW_WEAPONS[index][i] = weapon.getId();
                            }
                        } else {
                            for (int i = 0; i < DO_NO_DRAW_WEAPONS[index].length; i++) {
                                DO_NO_DRAW_WEAPONS[index][i] = null;
                            }
                        }
                        break;
                    case '3':
                        index = 2;
                        if (DO_NO_DRAW_WEAPONS[index].length == 0) {
                            List<WeaponGroupAPI> weaponGroups = engine.getPlayerShip().getWeaponGroupsCopy();
                            List<WeaponAPI> weapons = weaponGroups.get(0).getWeaponsCopy();
                            for (int i = 0; i < weapons.size(); i++) {
                                WeaponAPI weapon = weapons.get(i);
                                DO_NO_DRAW_WEAPONS[index][i] = weapon.getId();
                            }
                        } else {
                            for (int i = 0; i < DO_NO_DRAW_WEAPONS[index].length; i++) {
                                DO_NO_DRAW_WEAPONS[index][i] = null;
                            }
                        }
                        break;
                    case '4':
                        index = 3;
                        if (DO_NO_DRAW_WEAPONS[index].length == 0) {
                            List<WeaponGroupAPI> weaponGroups = engine.getPlayerShip().getWeaponGroupsCopy();
                            List<WeaponAPI> weapons = weaponGroups.get(0).getWeaponsCopy();
                            for (int i = 0; i < weapons.size(); i++) {
                                WeaponAPI weapon = weapons.get(i);
                                DO_NO_DRAW_WEAPONS[index][i] = weapon.getId();
                            }
                        } else {
                            for (int i = 0; i < DO_NO_DRAW_WEAPONS[index].length; i++) {
                                DO_NO_DRAW_WEAPONS[index][i] = null;
                            }
                        }
                        break;
                    case '5':
                        index = 4;
                        if (DO_NO_DRAW_WEAPONS[index].length == 0) {
                            List<WeaponGroupAPI> weaponGroups = engine.getPlayerShip().getWeaponGroupsCopy();
                            List<WeaponAPI> weapons = weaponGroups.get(0).getWeaponsCopy();
                            for (int i = 0; i < weapons.size(); i++) {
                                WeaponAPI weapon = weapons.get(i);
                                DO_NO_DRAW_WEAPONS[index][i] = weapon.getId();
                            }
                        } else {
                            for (int i = 0; i < DO_NO_DRAW_WEAPONS[index].length; i++) {
                                DO_NO_DRAW_WEAPONS[index][i] = null;
                            }
                        }
                        break;
                }
            }
        }
        
        if (engine == null || engine.getCombatUI() == null) {
            return;
        }
        
        if (engine.isUIShowingDialog()) {
            return;
        }
        
        if (!engine.isSimulation() && !engine.isUIShowingHUD()) {
            return;
        }
        if (engine.getCombatUI().isShowingCommandUI()) {
            return;
        }
        
        player = engine.getPlayerShip();
        if (player == null || !engine.isEntityInPlay(player)) {
            return;
        }
        
        ViewportAPI viewport = engine.getViewport();
        
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        final int width = (int) (Display.getWidth() * Display.getPixelScaleFactor()), height
                = (int) (Display.getHeight()
                * Display.getPixelScaleFactor());
        GL11.glViewport(0, 0, width, height);
        
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glOrtho(viewport.getLLX(), viewport.getLLX() + viewport.getVisibleWidth(), viewport.getLLY(),
                viewport.getLLY() + viewport.getVisibleHeight(), -1,
                1);
        
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glTranslatef(0.01f, 0.01f, 0);
        
        this.handleDraw();
        
        GL11.glDisable(GL11.GL_BLEND);
        
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        
        GL11.glPopAttrib();
    }
    
    private static void glColor(Color color) {
        GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(),
                (byte) (41f));
    }
    
    private void handleDraw() {
        List<WeaponAPI> weapons = engine.getPlayerShip().getAllWeapons();
        
        for (WeaponAPI weapon : weapons) {
            boolean skip = false;
            for (int i = 0; i < DO_NO_DRAW_WEAPONS.length; i++) {
                for (int j = 0; j < DO_NO_DRAW_WEAPONS[i].length; j++) {
                    if (DO_NO_DRAW_WEAPONS[i][j] == weapon.getId()) {
                    skip = true;
                }
                }
            }
            if (skip) {
                continue;
            }
            
            this.drawWeaponFacing(weapon);
            this.drawWeaponArc(weapon);
        }
    }
    
    private void drawWeaponFacing(WeaponAPI weapon) {
        
        if (!weapon.isDisabled()) {
            Vector2f location = weapon.getLocation();
            float cangle = weapon.getCurrAngle();
            Vector2f toRotate = new Vector2f(location.x + weapon.getRange(), location.y);
            Vector2f dest = new Vector2f(0, 0);
            VectorUtils.rotateAroundPivot(toRotate, location, cangle, dest);
            
            toRotate = new Vector2f(location.x + 5, location.y);
            Vector2f start = new Vector2f(0, 0);
            VectorUtils.rotateAroundPivot(toRotate, location, cangle, start);
            
            this.glColor(WEAPON_ARC_COLOR);
            
            this.drawLine(start, dest);
        }
        
    }
    
    private void drawWeaponArc(WeaponAPI weapon) {
        
        if (!weapon.isDisabled()) {
            Vector2f location = weapon.getLocation();
            float arc = weapon.getArc();
            float arcFacing = weapon.getArcFacing();
            float left = arcFacing - (arc / 2);
            float right = arcFacing + (arc / 2);
            Vector2f toRotateLeft = new Vector2f(location.x + weapon.getRange(), location.y);
            Vector2f destLeft = new Vector2f(0, 0);
            VectorUtils.rotateAroundPivot(toRotateLeft, location, left, destLeft);
            Vector2f toRotateRight = new Vector2f(location.x + weapon.getRange(), location.y);
            Vector2f destRight = new Vector2f(0, 0);
            VectorUtils.rotateAroundPivot(toRotateRight, location, right, destRight);
            
            float shipFacing = engine.getPlayerShip().getFacing();
            
            Vector2f finalLeft = new Vector2f(0, 0);
            Vector2f finalRight = new Vector2f(0, 0);
            
            VectorUtils.rotateAroundPivot(destLeft, location, shipFacing, finalLeft);
            VectorUtils.rotateAroundPivot(destRight, location, shipFacing, finalRight);
            
            Vector2f toRotateLeft2 = new Vector2f(location.x + 10, location.y);
            Vector2f destLeft2 = new Vector2f(0, 0);
            VectorUtils.rotateAroundPivot(toRotateLeft2, location, left, destLeft2);
            Vector2f toRotateRight2 = new Vector2f(location.x + 10, location.y);
            Vector2f destRight2 = new Vector2f(0, 0);
            VectorUtils.rotateAroundPivot(toRotateRight2, location, right, destRight2);
            
            Vector2f finalLeft2 = new Vector2f(0, 0);
            Vector2f finalRight2 = new Vector2f(0, 0);
            
            VectorUtils.rotateAroundPivot(destLeft2, location, shipFacing, finalLeft2);
            VectorUtils.rotateAroundPivot(destRight2, location, shipFacing, finalRight2);
            
            this.glColor(WEAPON_ARC_COLOR);
            
            this.drawLine(finalLeft2, finalLeft);
            this.drawLine(finalRight2, finalRight);
            
            int segments = (int) arc / 10;
            
            float startArc = right;
            
            float xdif = (finalLeft.x - location.x) / 4;
            float ydif = (finalLeft.y - location.y) / 4;
            
            this.drawArc(location,
                    finalLeft,
                    arc,
                    segments);
            
            this.drawArc(location,
                    new Vector2f(finalLeft.x - xdif, finalLeft.y - ydif),
                    arc,
                    segments);
            
            this.drawArc(location,
                    new Vector2f(finalLeft.x - xdif * 2, finalLeft.y - ydif * 2),
                    arc,
                    segments);
            
            this.drawArc(location,
                    new Vector2f(finalLeft.x - xdif * 3, finalLeft.y - ydif * 3),
                    arc,
                    segments);
            
        }
    }
    
    private void drawArc(Vector2f center, Vector2f start, float range, int segments) {
        Vector2f oldPoint = start;
        
        float rotation = range / segments;
        for (int i = 0; i < segments; i++) {
            Vector2f newpoint = new Vector2f(0f, 0f);
            VectorUtils.rotateAroundPivot(oldPoint, center, rotation, newpoint);
            this.drawLine(oldPoint, newpoint);
            oldPoint = newpoint;
        }
    }
    
    private void drawLine(Vector2f start, Vector2f end) {
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2f(start.x, start.y);
        GL11.glVertex2f(end.x, end.y);
        GL11.glEnd();
    }
}

[close]
Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Snrasha on July 21, 2018, 12:55:31 PM
I've been trying to implement switching weapon groups off, but i hit a snag:


http://fractalsoftworks.com/forum/index.php?topic=13431.0

Already exist, do not implement thing than people have already made :p
Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Archigo on July 21, 2018, 02:36:08 PM
You misunderstand, i meant switching the drawing on and off, not the actual weapon group. So that you could, for example, draw only group 1, 2, 3 but not 4 and 5.
Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Snrasha on July 22, 2018, 02:00:21 AM
You misunderstand, i meant switching the drawing on and off, not the actual weapon group. So that you could, for example, draw only group 1, 2, 3 but not 4 and 5.

After, on my head: getWeaponGroupsCopy();


A copy  is not linked to the ship where you got the copy, this is just for take informations without modify the ship per error.
Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Archigo on July 22, 2018, 04:45:30 AM
That's okay for my purposes. What i don't understand is why i get the compile error.
Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Snrasha on July 22, 2018, 06:58:16 AM
I do not found these "isempty" and size, on your code.

But ArrayList is the standard list you use when you need a list.

You have not forgot to import the ArrayList?
Title: Re: [0.8.1a] Weapon Arcs 1.0
Post by: Archigo on July 22, 2018, 08:58:16 AM
The arraylist issues is not in the code i posted.

Have you tried copying the code from the spoilers, into the java file in the mod and running starsector? That is the issue i am having trouble with.

Edit: All my issues got solved by compiling as a jar instead of letting Janino compile.
Title: Re: [0.8.1a] Weapon Arcs 1.1
Post by: Archigo on July 22, 2018, 03:06:45 PM
Version 1.1 of the mod has been released. Check OP.
Title: Re: [0.8.1a] Weapon Arcs 1.1
Post by: TauKinth on August 02, 2018, 08:05:15 PM
I never knew I needed this.  :o
Thanks for making my mods list +1 longer!
Title: Re: [0.9a] Weapon Arcs 1.2
Post by: Archigo on November 19, 2018, 02:12:15 PM
released for 0.9. Also updated the mod to have arcs off by default. It was kinda obnoxious to turn the groups you didn't want to see off every time
Title: Re: [0.9a] Weapon Arcs 1.2
Post by: Deshara on November 19, 2018, 06:53:18 PM
https://www.youtube.com/watch?v=ZhZYAL_7nMg
Title: Re: [0.9a] Weapon Arcs 1.2.1
Post by: Archigo on November 20, 2018, 10:43:27 AM
Updated the download link, so that it actually points to the new version. Also implemented version checker support.
Title: Re: [0.9a] Weapon Arcs 1.2.1
Post by: awpmax on December 02, 2018, 09:01:54 AM
Very usefull mod,I like it, huge Thank You.

I'm just asking, if You could implement some features. (Not like You should, just asking)

1. Automatically turn off/on vanilla weapon arcs, (even if hotkey is changed) and turn on/off modded ones, every battle.
2. Change and/or toggle transparency of modded arcs.
3. Make .cfg file for configuring those functions. Maybe also turning on arcs for each weapon group separately. Maybe make currently used arc less transparent while other stay transparent.
4. (Is it even possible) Show arcs for hostile/friendly ships with a hotkey for each group.

It would be awesome if You added those. Still very nice mod, I think devs should integrate it into the game.
Actually maybe propose to integrate it? I mean this looks like it should be in game permanently, not just mod.
Maybe add a poll about integration before proposing to devs, just as an idea?

Thank You for such usefull mod!
Title: Re: [0.9a] Weapon Arcs 1.2.1
Post by: cybersol on December 16, 2018, 03:40:19 PM
Also implemented version checker support.

I'm on linux which has case sensitive filenames, and I encountered an error until I changed the filename "weaponarcs.version" to "WeaponArcs.version". Cheers!
Title: Re: [0.9a] Weapon Arcs 1.2.1
Post by: evilphish on December 17, 2018, 04:24:34 AM
Small bug report regarding case mixups. Under Linux with a case sensitive filesystem your mod fails to load as it can not find the version file.

In your mod folder:
Code
weaponarcs.version
should be named
Code
WeaponArcs.version

cheers
Phishy

Title: Re: [0.9a] Weapon Arcs 1.2.1
Post by: Archigo on December 17, 2018, 07:31:52 AM
1. Automatically turn off/on vanilla weapon arcs, (even if hotkey is changed) and turn on/off modded ones, every battle.
2. Change and/or toggle transparency of modded arcs.
3. Make .cfg file for configuring those functions. Maybe also turning on arcs for each weapon group separately. Maybe make currently used arc less transparent while other stay transparent.
4. (Is it even possible) Show arcs for hostile/friendly ships with a hotkey for each group.

They're all possible, even number 4. I will probably not get around to doing these any time soon, but if you open a pull request on the github, I will happily merge your updates into the mod :)

I agree with you that the features of this mod would make a lot of sense to have as part of the base game.

Also implemented version checker support.

I'm on linux which has case sensitive filenames, and I encountered an error until I changed the filename "weaponarcs.version" to "WeaponArcs.version". Cheers!

Thanks for spotting that! :)
Title: Re: [0.9a] Weapon Arcs 1.3.0
Post by: Thyrork on February 13, 2019, 08:31:38 AM
Quote
696681 [Thread-4] INFO  org.histidine.chatter.combat.ChatterCombatPlugin  - Chatter plugin initialized
696681 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [weapon-arcs-settings.json]
698906 [Thread-4] INFO  data.scripts.WeaponArcsPlugin  - Shipname: RSS Red Dwarf
699365 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at data.scripts.WeaponArcsPlugin.advance(WeaponArcsPlugin.java:96)
   at com.fs.starfarer.title.C.K$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.super.OoOO.o00000(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$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Upon entering combat. Let me know if you need the full mod list. Repeatable crash upon entering the same combat. Ill make a backup of the save.
Title: Re: [0.9a] Weapon Arcs 1.3.0
Post by: FreedomFighter on February 13, 2019, 09:12:43 AM
Having the same problem with 1.3.0. I was using the previous version and everything work fine until I updated it to the current one.
Title: Re: [0.9a] Weapon Arcs 1.3.0
Post by: Archigo on February 13, 2019, 09:17:32 AM
I just posted 1.3.1, where it should be fixed. Thanks for reporting.
Title: Re: [0.9a] Weapon Arcs 1.3.1
Post by: Thyrork on February 13, 2019, 02:29:09 PM
loaded the save and everything was fine.
Title: Crash with Diable Avionics Ship System
Post by: Randall Hynes on May 25, 2019, 07:04:45 AM
Very often, I'll crash when using the Pocket Gust's ship system (Assume Wing Control) from Diable Avionics, and starsector.log shows this at the very bottom.

Spoiler
761917 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at data.scripts.WeaponArcsPlugin.advance(WeaponArcsPlugin.java:89)
    at com.fs.starfarer.title.Object.float$Oo.o00000(Unknown Source)
    at com.fs.starfarer.combat.oOOO.B.super(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$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source
[close]

I tested this on a brand new campaign, without displaying any additional weapon groups, and it didn't crash in the simulator, but it did when in a real battle.

I've had it crash inside the simulator before, though, but I don't know if I was displaying weapon groups at the time.
Title: Re: Crash with Diable Avionics Ship System
Post by: Archigo on March 30, 2021, 08:32:53 AM
Very often, I'll crash when using the Pocket Gust's ship system (Assume Wing Control) from Diable Avionics, and starsector.log shows this at the very bottom.

Spoiler
761917 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at data.scripts.WeaponArcsPlugin.advance(WeaponArcsPlugin.java:89)
    at com.fs.starfarer.title.Object.float$Oo.o00000(Unknown Source)
    at com.fs.starfarer.combat.oOOO.B.super(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$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source
[close]

I tested this on a brand new campaign, without displaying any additional weapon groups, and it didn't crash in the simulator, but it did when in a real battle.

I've had it crash inside the simulator before, though, but I don't know if I was displaying weapon groups at the time.

I realize it's been two years.. but hopefully this crash has been fixed in the new version 1.4.0 :)
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: ck68 on April 04, 2021, 08:47:12 PM
Just to let you know download link needs to be updated, github version is up to date while download link is 1.3.1
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: Archigo on April 04, 2021, 11:24:53 PM
Just to let you know download link needs to be updated, github version is up to date while download link is 1.3.1

The download is pointing to the master branch, and when I use it, I get 1.4.0.

Not sure how you're getting 1.3.1.
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: Lprsti99 on April 09, 2021, 03:12:17 PM
Just to let you know download link needs to be updated, github version is up to date while download link is 1.3.1

The download is pointing to the master branch, and when I use it, I get 1.4.0.

Not sure how you're getting 1.3.1.

Mod_info.json correctly shows 1.4.0, but weaponarcs.version is still returning 1.3.1, causing version checker to think it's the old version. 
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: Archigo on April 09, 2021, 03:35:25 PM
Mod_info.json correctly shows 1.4.0, but weaponarcs.version is still returning 1.3.1, causing version checker to think it's the old version. 

Should be fixed now
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: Paul_Kauphart on May 11, 2021, 01:05:08 AM
hi, I've noticed you don't cover weapoon groups 6 and 7, will you update it in the future ?
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: Archigo on May 11, 2021, 03:35:53 AM
hi, I've noticed you don't cover weapoon groups 6 and 7, will you update it in the future ?

They are now supported in version 1.4.1
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: CountV on May 11, 2021, 06:16:11 AM
Thanks for coming back to update this, I find this mod really helpful for ranging multiple weapon groups while lining up shots with reapers/am blasters. Or broadside ships in general.
Title: Re: [0.95a] Weapon Arcs 1.4.0
Post by: Archigo on May 11, 2021, 06:25:24 AM
Glad to hear you like it. Broadside ships and missiles was my reason for creating the mod  :)
Title: Re: Crash with Diable Avionics Ship System
Post by: CrimsonPhalanx on May 30, 2021, 01:28:50 PM


I realize it's been two years.. but hopefully this crash has been fixed in the new version 1.4.0 :)
[/quote]

I'm using 1.4.1 and "assume wing control" from diable avionics and sadly it still crashes the game, at least in simulation, the moment I hit the skill the game crashes with a null error, removed the mod and now the system works fine.
I'm not sure if this problem applies to other mods with a similar system that allows you to take control of a secondary craft
Title: Re: Crash with Diable Avionics Ship System
Post by: Archigo on May 30, 2021, 03:01:14 PM

I'm using 1.4.1 and "assume wing control" from diable avionics and sadly it still crashes the game, at least in simulation, the moment I hit the skill the game crashes with a null error, removed the mod and now the system works fine.
I'm not sure if this problem applies to other mods with a similar system that allows you to take control of a secondary craft

I'm doing the mission "T minus zero" and there is no issue assuming wing control from the gust. Are you refitting the scenario with some other fighter? I've tested with the default wanzer and a flash bomber wing. No issues.
Title: Re: Crash with Diable Avionics Ship System
Post by: CrimsonPhalanx on May 31, 2021, 04:36:30 AM

I'm using 1.4.1 and "assume wing control" from diable avionics and sadly it still crashes the game, at least in simulation, the moment I hit the skill the game crashes with a null error, removed the mod and now the system works fine.
I'm not sure if this problem applies to other mods with a similar system that allows you to take control of a secondary craft

I'm doing the mission "T minus zero" and there is no issue assuming wing control from the gust. Are you refitting the scenario with some other fighter? I've tested with the default wanzer and a flash bomber wing. No issues.

I tested again
funny enough its does not crash in T minus zero or other missions, but when I go onto the simulation in campaign mode it crashes, not sure why, although I didn't test in actual battle
as for fighters so far it crashes no matter what I equip, and stops once I remove this mod

Spoiler
java.lang.NullPointerException
   at data.scripts.WeaponArcsPlugin.advance(WeaponArcsPlugin.java:111)
   at com.fs.starfarer.title.Object.L$Oo.super(Unknown Source)
   at com.fs.starfarer.combat.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.B.super(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]
Title: Re: Crash with Diable Avionics Ship System
Post by: Archigo on May 31, 2021, 06:25:15 AM

I'm using 1.4.1 and "assume wing control" from diable avionics and sadly it still crashes the game, at least in simulation, the moment I hit the skill the game crashes with a null error, removed the mod and now the system works fine.
I'm not sure if this problem applies to other mods with a similar system that allows you to take control of a secondary craft

I'm doing the mission "T minus zero" and there is no issue assuming wing control from the gust. Are you refitting the scenario with some other fighter? I've tested with the default wanzer and a flash bomber wing. No issues.

I tested again
funny enough its does not crash in T minus zero or other missions, but when I go onto the simulation in campaign mode it crashes, not sure why, although I didn't test in actual battle
as for fighters so far it crashes no matter what I equip, and stops once I remove this mod

Spoiler
java.lang.NullPointerException
   at data.scripts.WeaponArcsPlugin.advance(WeaponArcsPlugin.java:111)
   at com.fs.starfarer.title.Object.L$Oo.super(Unknown Source)
   at com.fs.starfarer.combat.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.B.super(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]


What is your modlist? I can not reproduce this.
Title: Re: Crash with Diable Avionics Ship System
Post by: CrimsonPhalanx on May 31, 2021, 08:21:10 AM

I'm using 1.4.1 and "assume wing control" from diable avionics and sadly it still crashes the game, at least in simulation, the moment I hit the skill the game crashes with a null error, removed the mod and now the system works fine.
I'm not sure if this problem applies to other mods with a similar system that allows you to take control of a secondary craft

I'm doing the mission "T minus zero" and there is no issue assuming wing control from the gust. Are you refitting the scenario with some other fighter? I've tested with the default wanzer and a flash bomber wing. No issues.

I tested again
funny enough its does not crash in T minus zero or other missions, but when I go onto the simulation in campaign mode it crashes, not sure why, although I didn't test in actual battle
as for fighters so far it crashes no matter what I equip, and stops once I remove this mod

Spoiler
java.lang.NullPointerException
   at data.scripts.WeaponArcsPlugin.advance(WeaponArcsPlugin.java:111)
   at com.fs.starfarer.title.Object.L$Oo.super(Unknown Source)
   at com.fs.starfarer.combat.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.B.super(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]


What is your modlist? I can not reproduce this.

Since my modlist is very big I decided to look around some other mods to help narrow down the culprits
and suddenly even I can't replicate it anymore even when its the same setup that worked 4-6 times earlier.
I'll update you if I find out more information or crash again, for now just assume my game state/save was cursed or something at the time. Apologies for the trouble.
Title: Re: [0.95a] Weapon Arcs 1.4.1
Post by: Maniaks on July 31, 2021, 12:34:30 AM
Any way to make the arcs more round/smooth? I know it's stupid thing, but the vanilla arcs are more smooth and this is annoying me  ;D
Title: Re: [0.95a] Weapon Arcs 1.4.1
Post by: Archigo on September 23, 2021, 11:06:48 AM
Any way to make the arcs more round/smooth? I know it's stupid thing, but the vanilla arcs are more smooth and this is annoying me  ;D

In version 1.5.0 there is now a setting to change this. put in a lower number to get a smoother arc.
Title: Re: [0.95a] Weapon Arcs 1.5.0
Post by: KZadBhat on September 30, 2021, 02:27:09 AM
Working so well and lovely so far, but I'm wondering if there's a chance of using color coded arcs. It would make it easier to tell what weapon has what range if each could be a different color.
Title: Re: [0.95a] Weapon Arcs 1.5.0
Post by: Helldiver on September 30, 2021, 11:58:20 AM
Working so well and lovely so far, but I'm wondering if there's a chance of using color coded arcs. It would make it easier to tell what weapon has what range if each could be a different color.

Do you mean separate colors for each weapon group or different colors for weapon arcs within a same group?
Title: Re: [0.95a] Weapon Arcs 1.5.0
Post by: Archigo on October 01, 2021, 12:01:05 AM
Working so well and lovely so far, but I'm wondering if there's a chance of using color coded arcs. It would make it easier to tell what weapon has what range if each could be a different color.

In version 1.6.0 you can now set individual colors for weapon groups from the settings file.
Title: Re: [0.95a] Weapon Arcs 1.5.0
Post by: Helldiver on October 01, 2021, 05:09:31 AM
Working so well and lovely so far, but I'm wondering if there's a chance of using color coded arcs. It would make it easier to tell what weapon has what range if each could be a different color.

In version 1.6.0 you can now set individual colors for weapon groups from the settings file.

Damn that's awesome.
Title: Re: [0.95a] Weapon Arcs 1.6.0
Post by: KZadBhat on October 02, 2021, 06:09:26 AM
Exactly what I was hoping for, thank you very much! Makes the firing conditions a great deal more decipherable. This may in fact be the most useful mod, and getting better all the time.
Title: Re: [0.95a] Weapon Arcs 1.6.0
Post by: Mr_8000 on October 07, 2021, 08:09:22 PM
The added toggle workaround seems to be affecting the standard alt key as well, I can no long hold alt+number, instead I press alt and toggle with the number keys then press it again. This wouldn't be much of an issue except that every time I tab out and then in again the moment I swap weapon groups the arcs start appearing.
Title: Re: [0.95a] Weapon Arcs 1.6.0
Post by: Larkeith on July 01, 2022, 02:22:32 AM
I've submitted a pull request that adds an option to configure the number of range bands the weapon arcs show - with the default setting of 4, the behaviour is unchanged. Personally I have it set to 1, as it helps improve clarity and reduce visual noise.

With rangeBands = 1 (Showing only the outermost)
Spoiler
(https://imgpile.com/images/RX4Y2u.png)
[close]
rangeBands = 10 (I'm not sure why you would do this)
Spoiler
(https://imgpile.com/images/RX4PKi.png)
[close]
rangeBands = 0 (I'm not sure why you would do this either, unless you only care about where your guns are pointing. I might submit another PR with an option to disable the arc edges at some point, because that could be useful.)
Spoiler
(https://imgpile.com/images/RX4iak.png)
[close]

The tweaked mod can be found at https://github.com/Lrizika/WeaponArcsStarsector/raw/master/WeaponArcs.zip
Title: Re: [0.95a] Weapon Arcs 1.6.0
Post by: Archigo on July 02, 2022, 01:53:18 PM
I've submitted a pull request that adds an option to configure the number of range bands the weapon arcs show - with the default setting of 4, the behaviour is unchanged. Personally I have it set to 1, as it helps improve clarity and reduce visual noise.

With rangeBands = 1 (Showing only the outermost)
Spoiler
(https://imgpile.com/images/RX4Y2u.png)
[close]
rangeBands = 10 (I'm not sure why you would do this)
Spoiler
(https://imgpile.com/images/RX4PKi.png)
[close]
rangeBands = 0 (I'm not sure why you would do this either, unless you only care about where your guns are pointing. I might submit another PR with an option to disable the arc edges at some point, because that could be useful.)
Spoiler
(https://imgpile.com/images/RX4iak.png)
[close]

The tweaked mod can be found at https://github.com/Lrizika/WeaponArcsStarsector/raw/master/WeaponArcs.zip

The pull request has been merged into the main branch and is now available.

Thanks for the good work  :)
Title: Re: [0.95a] Weapon Arcs 1.7.0
Post by: Liral on July 26, 2022, 05:26:37 PM
I want to apply and extend your mod to display the weapon arcs of a targeted ship.  May I please do so?
Title: Re: [0.95a] Weapon Arcs 1.7.0
Post by: KZadBhat on May 06, 2023, 10:10:22 AM
Quick test shows that just updating the mod_info.json file, so the gameVersion reads "0.96a" has it working with no problem in the new version. Have not had the chance for extensive testing, and not even sure what all really needs to be tested for, but there's no crashing, and the arcs work fine using Mission mode.
Title: Re: [0.96a] Weapon Arcs 1.7.0
Post by: Archigo on May 25, 2023, 12:54:31 AM
Yeah the mod doesn't need any changes.
I've updated the version number for 0.96a.
Title: Re: [0.95a] Weapon Arcs 1.7.0
Post by: Archigo on May 25, 2023, 12:55:29 AM
I want to apply and extend your mod to display the weapon arcs of a targeted ship.  May I please do so?

Feel free to do so.
Title: Re: [0.96a] Weapon Arcs 1.7.0
Post by: Roibr on July 16, 2023, 08:35:47 AM
it would be really nice if the selected Weapon had a different Color than the rest!

thnx good mod
Title: Re: [0.96a] Weapon Arcs 1.7.0
Post by: KZadBhat on July 18, 2023, 01:45:06 PM
The latest version does allow color coding of weapon groups. Although perhaps a highlight color?

Honestly, this has developed well enough I think with a few tweaks, it could become an integral part of the game, rather than a mod.
Title: Re: [0.96a] Weapon Arcs 1.7.0
Post by: Archigo on February 04, 2024, 09:31:14 AM
1.7.1 - Updated version number for 0.97a-RC6
Title: Re: [0.97a] Weapon Arcs 1.7.1
Post by: SpiralMatai on February 10, 2024, 09:30:49 AM
What does the fourth number do in the color settings? (set to 102 by default) Can't figure it out.
Title: Re: [0.97a] Weapon Arcs 1.7.1
Post by: Archigo on February 10, 2024, 09:36:45 AM
It is Red Green Blue Alpha, or in other words it is how strong/transparent the color is.
Title: Re: [0.97a] Weapon Arcs 1.7.1
Post by: digitalizedMind on March 17, 2024, 08:35:31 PM
I like it, however I use Alt as the ship system button so it's annoying that there isn't an option to turn that off.
Title: Re: [0.97a] Weapon Arcs 1.7.1
Post by: Archigo on March 18, 2024, 04:19:03 PM
I like it, however I use Alt as the ship system button so it's annoying that there isn't an option to turn that off.

In 1.7.2 you can unbind the Alt key
Title: Re: [0.97a] Weapon Arcs 1.7.2
Post by: FreedomFighter on March 19, 2024, 08:15:34 PM
I'm I hallucinated or you can press "H" key once as a toggle then press group number instead of having to hold LAlt + Group number in one of the version before?
Title: Re: [0.97a] Weapon Arcs 1.7.2
Post by: Archigo on March 20, 2024, 02:23:17 AM
I'm I hallucinated or you can press "H" key once as a toggle then press group number instead of having to hold LAlt + Group number in one of the version before?

That was indeed possible earlier.
You can still use the "h" key by setting it as the toggleKey in settings.
You will have to hold it while pressing the weapon groups though