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)

Pages: 1 ... 393 394 [395] 396 397 ... 706

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

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5910 on: January 03, 2020, 06:06:02 PM »


Just a thought that occurred:

For each modded station type you wanted to merge with Better Colonies, could you add your own csv entries for each station industry copy from the mod in question and give it a unique industry id so it would merge with other mods industries.csv? That way, in that entry you can call your custom implementation of com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java

Then you can use a procedural script under onNewGameAfterEconomyLoad() to check for the original industry id from each station in the campaign and replace it with the industry id that will call your mod's OrbitalStation.java replacement.

However some friendly advice:

That kind of implementation requires you to copy other modders industries which to some modders could be considered intrusively changing their mod since other values in the industry entry might change in later updates of their mod that would have to be reflected into the copies of your industry entries with the unique id (each time it changes on their end).

So if wanting to do this, please get permission from the mod author for each mod you want to do this with and make sure they understand the full consequences of what that entails. It will create a soft dependency to maintain compatibility and prevent unintended inconsistency when the two mods are both present on a mod list.

That being said, you have my permission to do this with Archean Order stations and I'll try to remember to update you with any changes I make in the future to the industries.csv entries for my stations.  :)
I've originally considered it and that might work for past stations, but hypothetical if future stations were made, they would not inherit my changes.

As for Archean Order, I've considered making a separate version for Archean Order users.

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5911 on: January 03, 2020, 09:09:43 PM »

I've originally considered it and that might work for past stations, but hypothetical if future stations were made, they would not inherit my changes.

As for Archean Order, I've considered making a separate version for Archean Order users.

That is very generous of you!  ;D

Let me know if I can help with anything, and I will add a link and credit to Archean Order's main mod page. (Makes another mental note that much of the main page is really outdated and needs some work.)
Logged

WadeStar

  • Ensign
  • *
  • Posts: 30
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5912 on: January 03, 2020, 09:30:39 PM »

However, since the eagle and the legion are both part of "lowtech_bp" and "midline_bp"

They're not, those are both rare_bp, as is the Onslaught.

I know for a fact the Hegemony also spawn Falcons (part of the midline bp).


Well egg on my face! Thanks! I can't believe I didn't figure it out.
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5913 on: January 03, 2020, 09:32:27 PM »

I have a system with a hidden planet and hidden market. I want to add a second planet that is also hidden, owned by the same faction, and that can trade with the first planet (while both remain hidden from the main sector economy). So far, I have generated the planet, but I don't know how to get the two planets to trade. Is there a way to do this?

And a related question: the planet is hidden, but the system appears as having been explored on the map. How can I set it to start as unexplored?

And a third question: Is it possible to have my faction's data added to the Faction tab of the Intel screen, despite being a hidden market? If possible, I would like it to appear there when the faction is first encountered during a playthrough. But, failing that, I would like it to show up by default.
« Last Edit: January 03, 2020, 11:03:16 PM by Sinosauropteryx »
Logged

Razor98566

  • Ensign
  • *
  • Posts: 36
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5914 on: January 04, 2020, 07:19:15 AM »

Hello there,
right now I'm trying to add a faction to the campaign, while I am making progress I have hit a little wall. I have everything set up so far (the .faction, .gen and spawnpoint.java files) I'm getting an error on startup which tells me that the createFleet function from the Spawnpoint file isn't declared. I have been following this tutorial so I have no idea what I have to import to get that function.

Here are the error messages and my SpawnPoint.java file:
Spoiler
Code
java.lang.RuntimeException: Error compiling [data.scripts.world.ColSpawnPoint]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/world/ColSpawnPoint.java', Line 34, Column 56: A method named "createFleet" is not declared in any enclosing class nor any supertype, nor through a static import
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/world/ColSpawnPoint.java', Line 34, Column 56: A method named "createFleet" is not declared in any enclosing class nor any supertype, nor through a static import
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

public class ColSpawnPoint extends BaseSpawnPoint {

   public ColSpawnPoint(SectorAPI sector, LocationAPI location, loat daysInterval, int maxFleets, SectorEntityToken anchor) {
      super(sector, location, daysInterval, maxFleets, anchor);
   }

   @Override
   protected CampaignFleetAPI spawnFleet() {
     
      String type = null; 
      float r = (float) Math.random();
      if (r > .8f) {
         type = "Scout";
      } else if (r > 0.45f) {
         type = "Security Detachment";
      } else if (r > 0.3f) {
         type = "Task Force";
      } else if (r > 0.15f) {
         type = "Strike Team";
      } else if (r > 0.05f) {
         type = "Security Detachment";
      } else {
         type = "Task Force";
      }
     
      CampaignFleetAPI fleet = getSector().createFleet("bsg_colonies", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
     
     
      if (type.equals("Scout") || type.equals("Security Detachment") || type.equals("Task Force") || type.equals("Strike Team")) {
         fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10);
         fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN,  getAnchor(), 1000);
      } else {
         if ((float) Math.random() > 0.5f) {
            fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 30);
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
         } else {
            fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 20);
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
         }
      }
     
      return fleet;
   }

}
[close]

Help would be greatly appreciated! ^^
Logged
Check out my mods!

ActuallyUlysses

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5915 on: January 04, 2020, 09:47:53 AM »

Hi,
so I am trying to figure out how game decides how shields look like.

I noticed that sometimes shields are stable + blue color and sometimes unstable + red-ish. I played around with changing shield upkeep and shield efficiency values and while I was able to make shield look unstable, I was not able to make them have that red-ish tint that you get if you use ie. makeshift shield emitter hullmod.

So... anyone knows how to get red tint? :D
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5916 on: January 04, 2020, 10:34:30 AM »

I have a system with a hidden planet and hidden market. I want to add a second planet that is also hidden, owned by the same faction, and that can trade with the first planet (while both remain hidden from the main sector economy). So far, I have generated the planet, but I don't know how to get the two planets to trade. Is there a way to do this?

Call market.setEconGroup(<group id>) for both of those markets with the same parameter, and they should trade with each other (and other markets with the same econGroup, if any).

And a related question: the planet is hidden, but the system appears as having been explored on the map. How can I set it to start as unexplored?

Hmm - hidden pirate bases have markets but don't show up this way, so I'd suggest trying to see what's different about your case. They're defined in PirateBaseIntel.java

And a third question: Is it possible to have my faction's data added to the Faction tab of the Intel screen, despite being a hidden market? If possible, I would like it to appear there when the faction is first encountered during a playthrough. But, failing that, I would like it to show up by default.

That's unrelated to the markets in is controlled via:

"showInIntelTab":true (or false)

In the .faction file.


Hello there,
right now I'm trying to add a faction to the campaign, while I am making progress I have hit a little wall. I have everything set up so far (the .faction, .gen and spawnpoint.java files) I'm getting an error on startup which tells me that the createFleet function from the Spawnpoint file isn't declared. I have been following this tutorial so I have no idea what I have to import to get that function.

Here are the error messages and my SpawnPoint.java file:
...

Hmm. Well, BaseSpawnPoint is not a class that exists, so I suspect you're basing your code on some very, very old examples found somewhere? I'd suggest starting over fresh with something more recent, and probably setting up an IDE - in the long run, that'd save you time tracking down these sorts of issues.



Hi,
so I am trying to figure out how game decides how shields look like.

I noticed that sometimes shields are stable + blue color and sometimes unstable + red-ish. I played around with changing shield upkeep and shield efficiency values and while I was able to make shield look unstable, I was not able to make them have that red-ish tint that you get if you use ie. makeshift shield emitter hullmod.

So... anyone knows how to get red tint? :D

See: hull_styles.json; the shield color is among the things that's defined there. You'd want to create your own new hull style (probably based on copy-pasting an existing one, then tweaking the shield color/whatever else) and then set your ship to use it.
Logged

ActuallyUlysses

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5917 on: January 04, 2020, 11:54:43 AM »

See: hull_styles.json; the shield color is among the things that's defined there. You'd want to create your own new hull style (probably based on copy-pasting an existing one, then tweaking the shield color/whatever else) and then set your ship to use it.

Thanks for quick reply Alex :D

What I found after more research is that shield colors are determined by hull_styles.json, just like you said, and they need to be applied to ships via <hullname>.ship file of specific hull (ie. atlas.ship).

I had no idea about that second part, hence my confusion :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5918 on: January 04, 2020, 01:26:48 PM »

Cool, glad you worked it out :)
Logged

Razor98566

  • Ensign
  • *
  • Posts: 36
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5919 on: January 04, 2020, 03:23:01 PM »

Hello there,
right now I'm trying to add a faction to the campaign, while I am making progress I have hit a little wall. I have everything set up so far (the .faction, .gen and spawnpoint.java files) I'm getting an error on startup which tells me that the createFleet function from the Spawnpoint file isn't declared. I have been following this tutorial so I have no idea what I have to import to get that function.

Here are the error messages and my SpawnPoint.java file:
...

Hmm. Well, BaseSpawnPoint is not a class that exists, so I suspect you're basing your code on some very, very old examples found somewhere? I'd suggest starting over fresh with something more recent, and probably setting up an IDE - in the long run, that'd save you time tracking down these sorts of issues.

I have followed this tutorial (the only one I found, if there's a newer one pls let me know ^^): https://fractalsoftworks.com/forum/index.php?topic=1282.0

Might be a little outdated but I haven't found anything newer yet...

I thought about setting up my Intellij for starsector but thought it wasn't worth the effort, might do that tomorrow when I'm back at my pc :x
Logged
Check out my mods!

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5920 on: January 04, 2020, 03:38:39 PM »

I'd like to re-ask my previous questions, I think they were (understandably) buried during the holiday break.

- Is there a way to make a ship "braver" without changing its loadout? I'm not really sure how the backend deals with it, but I made a modular ship where the core is almost unarmed and has 1 fighter bay. It, however, has three huge modules with tons of close range weapons. However, instead of brawling up-close, it seems to prefer to act like a dedicated carrier and move far outside the range of its weapons or, even its short-ranged fighters (despite having the CARRIER, COMBAT tag - this behavior happens even if I remove all tags).

- Is there a way to trigger a script at a certain date? My aim is to spawn some planets/stations after some years have passed using the same code in the SectorGeneratorPlugin I used to create the system in the first place.

- I am having issues with issuing full retreat, but then the combat doesn't end even when there are no ships or fighters on my side anymore. Looking at other mods, they seem to have some plugins that take care of modules to solve this issue, however, when I tried porting it over to my files, it seems the function calls they use are deprecated...  Is there a workaround for this?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5921 on: January 04, 2020, 05:35:55 PM »

And a related question: the planet is hidden, but the system appears as having been explored on the map. How can I set it to start as unexplored?

Hmm - hidden pirate bases have markets but don't show up this way, so I'd suggest trying to see what's different about your case. They're defined in PirateBaseIntel.java
See updateKnownPlanets() in CoreLifecyclePlugin (which is called after economy load)
You could only add the market to the star system after economy load (but try adding the market to the economy first without it having an entity, so it gets processed by the economy load code, e.g. having admins added to its comm board). Or manually undo the effects of updateKnownPlanets.

- Is there a way to trigger a script at a certain date? My aim is to spawn some planets/stations after some years have passed using the same code in the SectorGeneratorPlugin I used to create the system in the first place.
I'd do an EveryFrameScript and query the sector clock for the date periodically. Or use a DelayedActionScript, if you know the exact number of days to wait.

Quote
- I am having issues with issuing full retreat, but then the combat doesn't end even when there are no ships or fighters on my side anymore. Looking at other mods, they seem to have some plugins that take care of modules to solve this issue, however, when I tried porting it over to my files, it seems the function calls they use are deprecated...  Is there a workaround for this?
The script for cleaning up the deployed fleet member list requires importing starfarer_obf.jar as a library. (It works by casting the API class CombatFleetManagerAPI to the core code class CombatFleetManager, in order to access and manipulate the deployed fleet member lists directly)
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5922 on: January 04, 2020, 08:54:26 PM »

Thanks, Alex and Histidine. I managed to get most of this working. But I'm still unsure about this part:
You could only add the market to the star system after economy load (but try adding the market to the economy first without it having an entity, so it gets processed by the economy load code, e.g. having admins added to its comm board).
How would I add a market after economy load? I'm pretty clueless about most campaign-layer stuff, or anything outside of combat really. Any examples I can look at?

Edit: Another question. I am trying to add an asteroid belt, and I can spawn the clickable asteroids themselves, but the dense-looking background asteroids that should make up the bulk of the visuals are not showing up. Is there a step I have to do besides system.AddAsteroidBelt()?
« Last Edit: January 04, 2020, 09:43:43 PM by Sinosauropteryx »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5923 on: January 05, 2020, 05:58:37 AM »

Thanks, Alex and Histidine. I managed to get most of this working. But I'm still unsure about this part:
You could only add the market to the star system after economy load (but try adding the market to the economy first without it having an entity, so it gets processed by the economy load code, e.g. having admins added to its comm board).
How would I add a market after economy load? I'm pretty clueless about most campaign-layer stuff, or anything outside of combat really. Any examples I can look at?
If you're adding the market in code (and I'm not sure hidden markets can be added through json), just call said code from mod plugin's onNewGameAfterEconomyLoad instead of onNewGame/onNewGameAfterProcgen. If you haven't added markets in code before, a bunch of mods have examples (e.g. see Underworld's Styx here, here).

Edit: Another question. I am trying to add an asteroid belt, and I can spawn the clickable asteroids themselves, but the dense-looking background asteroids that should make up the bulk of the visuals are not showing up. Is there a step I have to do besides system.AddAsteroidBelt()?
Add a ring band or two on top of it; the vanilla systems in data/scripts/world have examples.
Logged

Mongreal

  • Ensign
  • *
  • Posts: 46
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5924 on: January 05, 2020, 08:21:10 AM »

Hi everyone,

I'm back again with yet another script error.
I tried to mess a bit with missile IA :
Spoiler
Code
package data.scripts.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CollisionClass;
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 org.lazywizard.lazylib.MathUtils;
import java.awt.Color;
import java.util.List;

import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;
import data.scripts.util.MagicLensFlare;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.AIUtils;


public class SCQ_LongbowMissileAI implements MissileAIPlugin, GuidedMissileAI {

    private static final Color JITTER_COLOR = new Color(143, 169,255,75);
    private static final Color JITTER_UNDER_COLOR = new Color(123, 144,255,155);
   
    private CombatEngineAPI engine;
    public WeaponAPI weapon;
    private List<MissileAPI> missiles;
    private MissileAPI missile;
    private ShipAPI ship,
            launchingShip;
    private CombatEntityAPI target;
    private Vector2f targetLocation;
    private boolean runOnce = false;
    private String missileId = "LNC_waver_CN_mrm",
            missileTeleporterId = "LNC_longbow_waver_mrm_teleporter",
            teleportedMissileId = "LNC_waver_teleported";
    private float minTeleportRange = 1500.0f,
            jitterMinLevel = 20.0f,
            fluxIncrease = 200.0f,
            missileRange,
            teleportRange,
            targetRange,
            jitterLevel;

    //////////////////////
    //  DATA COLLECTING //
    //////////////////////

    public SCQ_LongbowMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        this.missile = missile;
        this.ship = launchingShip;
        this.weapon = missile.getWeapon();
        missileRange = missile.getMaxFlightTime() * missile.getMaxSpeed();
        missileRange = MathUtils.clamp(missileRange, 2500f, 3000f);
        teleportRange = missile.getWeapon().getRange() - missileRange ;
        teleportRange = MathUtils.clamp(teleportRange, 7000f, 10000f);
        runOnce = false;
        if (engine != Global.getCombatEngine()) {
            engine = Global.getCombatEngine();
        }
    }
   
    //////////////////////
    //   MAIN AI LOOP   //
    //////////////////////
   
    @Override
    public void advance(float amount) {
        //skip the AI if the game is paused, the missile is engine-less or fading
        if (engine == null) { //  || engine.isPaused() || missile.isFading() || missile.isFizzling()
                return;
            }
        if(missile != null && (missile.isFizzling() || missile.isFading() || missile.getFlightTime() > missile.getMaxFlightTime())){
            // Vector2f loc, Vector2f vel, Color color, float size, float duration
            engine.spawnExplosion(missile.getLocation(), missile.getVelocity(), new Color(112, 198, 240,200), 15f, 8f);
            //public void applyDamage(CombatEntityAPI entity, Vector2f point, float damageAmount, DamageType damageType, float empAmount, boolean bypassShields, boolean dealsSoftFlux, Object source)
            engine.applyDamage(missile, missile.getLocation(), missile.getHitpoints() * 2, DamageType.FRAGMENTATION, 0, true, false, missile.getSource());
            engine.removeEntity(missile);
            return;
        }
        //variables
        if (targetLocation == null) {
            if (ship.getMouseTarget() != null || !MathUtils.isWithinRange(missile.getLocation(), ship.getMouseTarget(), minTeleportRange)) {
                targetLocation = ship.getMouseTarget();
            } else if (ship.getShipTarget() != null && ship.getShipTarget().getLocation() != null) {
                targetLocation = ship.getShipTarget().getLocation();
            } else if (missile != null && AIUtils.getNearestEnemy(missile) != null) {
                targetLocation = AIUtils.getNearestEnemy(missile).getLocation();
            }
            targetRange = Misc.getDistance(missile.getLocation(), targetLocation);
            if (targetLocation != null) {
                if (targetRange > teleportRange) {
                    float dir = Misc.getAngleInDegrees(missile.getLocation(), targetLocation);
                    targetLocation = Misc.getUnitVectorAtDegreeAngle(dir);
                    targetLocation.scale(teleportRange);
                    Vector2f.add(targetLocation, missile.getLocation(), targetLocation);
                }
                targetLocation = findClearLocation(missile, targetLocation);
            }
        }
        if (!runOnce) {
            if (ship.getCurrFlux() + fluxIncrease >= ship.getMaxFlux() || targetRange < minTeleportRange) {
                Global.getSoundPlayer().playSound("short_range_lauch", 0.8f, 1.2f, ship.getLocation(), new Vector2f(0, 0));
                runOnce = true;
                return;
            } else if (targetLocation != null) { // && (missileRange + teleportRange >= targetRange)
                Global.getSoundPlayer().playSound("system_phase_skimmer", 0.8f, 1.2f, ship.getLocation(), new Vector2f(0,0));
                ship.getFluxTracker().setCurrFlux(ship.getCurrFlux() + fluxIncrease);
                teleportOnce(amount, missile, targetLocation);
                jitterLevel = jitterMinLevel * 1 + (ship.getCurrFlux() / ship.getMaxFlux());
                missile.setJitter(missile, JITTER_COLOR, jitterLevel, 4, 0f, 0 + (ship).getCurrFlux() / ship.getMaxFlux());
                runOnce = true;
                engine.removeEntity(missile);
                return;
            }
        }
        if (targetLocation == null) {
            missile.giveCommand(ShipCommand.ACCELERATE);
        } else {
            float aimAngle = MathUtils.getShortestRotation(missile.getFacing(), VectorUtils.getAngle(missile.getLocation(), targetLocation));
            if (Math.abs(aimAngle) < 45.0f) {
                missile.giveCommand(ShipCommand.ACCELERATE);
            }
            if (aimAngle < 0f) {
                missile.giveCommand(ShipCommand.TURN_RIGHT);
            }
            if (aimAngle > 0f) {
                missile.giveCommand(ShipCommand.TURN_LEFT);
            }
        }
    }

    void teleportOnce(float amount, MissileAPI missile, Vector2f targetLocation){
        if(targetLocation != null) {
                Global.getSoundPlayer().playSound("system_phase_skimmer", 1.2f, 0.5f, missile.getLocation(), new Vector2f(0,0));
            /**for (int i = 0; i < 12; i++) {
                Vector2f cPoint = MathUtils.getRandomPointInCircle(targetLocation, 25f);
                engine.addHitParticle(cPoint, new Vector2f ((float) Math.random() * 0.5f, (float) Math.random() * 0.5f), jitterLevel, jitterLevel, 0.5f, JITTER_COLOR);
            }*/
            if (ship != null && weapon != null && weapon.getShip() == ship) {
                //engine.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity)
                engine.spawnProjectile(
                        null,
                        null,
                        missileTeleporterId,
                        teleportedMissileId,
                        targetLocation,
                        missile.getFacing(),
                        new Vector2f (0f, 0f) //new Vector2f(0,0)
                );
            } else return;
        } else return;
    }

    private Vector2f findClearLocation(MissileAPI missile, Vector2f dest) {
        if (isLocationClear(dest)) return dest;
        float incr = 50f;
        WeightedRandomPicker<Vector2f> tested = new WeightedRandomPicker<Vector2f>();
        for (float distIndex = 1; distIndex <= 32f; distIndex *= 2f) {
            float start = (float) Math.random() * 360f;
            for (float angle = start; angle < start + 360; angle += 60f) {
                Vector2f loc = Misc.getUnitVectorAtDegreeAngle(angle);
                loc.scale(incr * distIndex);
                Vector2f.add(dest, loc, loc);
                tested.add(loc);
                if (isLocationClear(loc)) {
                    return loc;
                }
            }
        }
        if (tested.isEmpty()) return dest; // shouldn't happen
        return tested.pick();
    }

    private boolean isLocationClear(Vector2f loc) {
        for (ShipAPI other : Global.getCombatEngine().getShips()) {
            if (other.isShuttlePod()) continue;
            if (other.isFighter()) continue;
            float dist = Misc.getDistance(loc, other.getLocation());
            float r = other.getCollisionRadius();
            //r = Math.min(r, Misc.getTargetingRadius(loc, other, false) + r * 0.25f);
            if (dist < r + minTeleportRange) {
                return false;
            }
        }
        for (CombatEntityAPI other : Global.getCombatEngine().getAsteroids()) {
            float dist = Misc.getDistance(loc, other.getLocation());
            if (dist < other.getCollisionRadius() + minTeleportRange) {
                return false;
            }
        }
        return true;
    }

    @Override
    public CombatEntityAPI getTarget() {
        return target;
    }

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

And everything looks fine until one of the spawned missiles hit anything (ship, asteroid, shield, projectiles, other missiles, fighters, really anything), which give me a nullPointer...
Spoiler
Code
52777 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamage(Unknown Source)
at com.fs.starfarer.combat.class.super.O0OO.o00000(Unknown Source)
at com.fs.starfarer.combat.class.super.super(Unknown Source)
at com.fs.starfarer.combat.class.super.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]

My guess is that the engine doesn't know the source of the damage and can't apply it to the object hit. Doesn't work either if I'm using the missile's ship and weapon as source for the ShipAPI and WeaponAPI.
Any easy way to fix this ?
Logged
Pages: 1 ... 393 394 [395] 396 397 ... 706