Ran into a weird issue, looks like a bug.
Beam weapons that are doing EMP along with regular damage appear to be doing EMP-only damage if they hit Shields. Not happening vs. Armor, other attack types don't appear to be having this issue.
Was testing out stuff, and I have very minor EMP on the Phase Lance (the phasebeam-equivalent in Vanilla) and it never, ever, ever raised Hard Flux. Was like a pure-EMP weapon.
Stats:
Phase Lance,phasebeam,1,6500,1400,1300,,20,0,60,12,,,ENERGY,,225,0.5,1,,,,,,,2400,,,,,,20
Knocked out some code for this problem, but I've run into trouble.
1. BeamAPI didDamageThisFrame() always returns false, even when a beam's doing damage.
2. applyDamage() requires an entity ID to apply it to, but the entity that's being hit by a beam isn't being returned by getDamageTarget(), which always returns null.
Kind've stuck here; I can get the from / to vectors just fine but I need to know that the beam actually hit something and then I need to apply the damage to that something. Also, the BeamAPI doesn't return the damage dealt, so IDK how I'm going to get a damage number to apply some standard damage yet.
package data.scripts.plugins;
import java.awt.Color;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.lwjgl.util.vector.Vector2f;
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.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.mission.FleetSide;
public class TestCombatPlugin implements EveryFrameCombatPlugin {
/**
* Set this to true to have the plugin actually do stuff.
*/
private static boolean TEST_MODE = true;
private CombatEngineAPI engine;
private CombatEntityAPI entity;
public void init(CombatEngineAPI engine) {
this.engine = engine;
}
public void init(CombatEntityAPI entity) {
this.entity = entity;
}
public void advance(float amount, List events) {
if (!TEST_MODE) return;
if (engine.isPaused()) return;
List beams = engine.getBeams();
for (int i = 0; i < beams.size(); i++)
{
BeamAPI thisBeam = (BeamAPI) beams.get(i);
boolean didDamage = thisBeam.didDamageThisFrame();
//The above always returns false here
if (didDamage == false)
{
CombatEntityAPI beamTarget = thisBeam.getDamageTarget();
if (beamTarget == null){return;}
Vector2f source = thisBeam.getFrom();
Vector2f damageLoc = thisBeam.getTo();
/*if (beamTarget == null)
{
beamTarget = source;
}*/
float damage = 100f;
engine.addHitParticle(damageLoc, damageLoc, 5f, 1f, 3f, Color.YELLOW);
engine.applyDamage(beamTarget, source, damage,
DamageType.ENERGY, 0f, false, false, source);
} else if (didDamage == true) {
ShipAPI playerShip = engine.getPlayerShip();
if (playerShip != null && !playerShip.isShuttlePod()) {
engine.spawnProjectile(playerShip, null, "swarmer", playerShip.getLocation(),
(float) Math.random() * 360f, playerShip.getVelocity());
for (int b = 0; b < 1; b++) {
Vector2f loc = new Vector2f(playerShip.getLocation());
loc.x += 50f - 100f * (float) Math.random();
loc.y += 50f - 100f * (float) Math.random();
engine.addSmokeParticle(loc, playerShip.getVelocity(), 35f, 1f, 1f, new Color(100,100,100,255));
}
}
}
}
}
}