Hi people on the forum,
Here is VladimirVV, a player of starsector since 2015. I'm currently making a mod, and I met a silly question that I can't find answer to, any help would be appreciated!
The question is, I want to implement a weapon like death ray, a super laser that literally kills anything in its way but takes super long time to charge. The implementation is OK, and I find it fun to play with. The only problem is that the ai does NOT fire it under any circumstances.
For my own efforts regarding this issue, I tried to google for it and I found something like ai would not fire a weapon set if it costs more than 50% of the flux of the ship. And I made this weapon with purpose that it will fill almost 100% of the flux pool for the ship. I want to let the ai bypass this 50% flux threshold, how can I do it? (I don't want to lower the flux this weapon costs, otherwise the data of the weapon will look bizarre and make the ship quite unbalanced)
Thank you!
I've found adding the line:
"autocharge":true,
to your .wpn file will make the AI fire the weapon more reliably. Note that I've seen them turn the weapon or even the whole ship away from the target (like the AI thinks the weapon has already fired) before the charging weapon actually fires if the the chargeup time is extensive. If the AI still seems unable to use your weapon well, try balancing the chargeup and chargedown times.
@accuracyThruVolume are you using a proper java IDE? all of these mistakes are minor syntax errors that one would automatically correct for you.
The wiki has a guide for setting up intellij here that should only take a few minutes & will make things so much easier compared to using something like notepad++
Thanks for the pointer on the IDE Ruddygreat!
I was able to get the missileAI working / not complaining / not crashing the game. I'm still a little lost on the correct implementation of the forceflameout command. IntelliJ is useful indeed for the "hey this patch of code is no good"
Currently my fusion blaster onfire code is:
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;
public class FusionBlasterOnFireEffect implements OnFireEffectPlugin
{
public static final float OVERLOADCHANCE = 10f;
public static final float FLAMEOUTCHANCE = 1f;
private ShipEngineControllerAPI shipengine;
public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
{
// Percentage chance (1 - 100)
int rndChance = (int)Math.round((Math.random() * 99)+ 1);
if (rndChance <= OVERLOADCHANCE)
{
// something here to get each engine, chance to flameout each one individually?
}
if (rndChance <= FLAMEOUTCHANCE)
{
ShipAPI ship = weapon.getShip();
//ship.ShipEngineControllerAPI.forceFlameout(); <--- this doesn't work
//ShipEngineAPI.forceFlameout(); <--- this doesn't work either
}
}
}
So my current stumbling block is what is the proper command to tell my ship to flameout.
Also the reference for getShipEngines just shows:
getShipEngines
java.util.List<ShipEngineControllerAPI.ShipEngineAPI> getShipEngines()
So It's unclear what the return value is. My first guess is an array of the ship's engines?
EDIT:
Ok so I dug around in ShipEngineControllerAPI.java and it looks like it returns a list?
List<ShipEngineAPI> getShipEngines();
Is there an example of how to use this function to capture a list of engines?