29 public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {
31 float emp = projectile.getEmpAmount();
32 float dam = projectile.getDamageAmount();
34 CombatEntityAPI target =
findTarget(projectile, weapon, engine);
35 float thickness = 20f;
36 float coreWidthMult = 0.67f;
37 Color color = weapon.getSpec().getGlowColor();
39 EmpArcEntityAPI arc = engine.spawnEmpArc(projectile.getSource(), projectile.getLocation(), weapon.getShip(),
45 "shock_repeater_emp_impact",
48 new Color(255,255,255,255)
50 arc.setCoreWidthOverride(thickness * coreWidthMult);
51 arc.setSingleFlickerMode();
53 Vector2f from =
new Vector2f(projectile.getLocation());
55 EmpArcEntityAPI arc = engine.spawnEmpArcVisual(from, weapon.getShip(), to, weapon.getShip(), thickness, color, Color.white);
56 arc.setCoreWidthOverride(thickness * coreWidthMult);
57 arc.setSingleFlickerMode();
62 public Vector2f
pickNoTargetDest(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {
64 float range = weapon.getRange() - spread;
65 Vector2f from = projectile.getLocation();
66 Vector2f dir = Misc.getUnitVectorAtDegreeAngle(weapon.getCurrAngle());
68 Vector2f.add(from, dir, dir);
69 dir = Misc.getPointWithinRadius(dir, spread);
73 public CombatEntityAPI
findTarget(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {
74 float range = weapon.getRange();
75 Vector2f from = projectile.getLocation();
78 range * 2f, range * 2f);
79 int owner = weapon.getShip().getOwner();
80 CombatEntityAPI best =
null;
81 float minScore = Float.MAX_VALUE;
83 ShipAPI ship = weapon.getShip();
84 boolean ignoreFlares = ship !=
null && ship.getMutableStats().getDynamic().getValue(Stats.PD_IGNORES_FLARES, 0) >= 1;
85 ignoreFlares |= weapon.hasAIHint(AIHints.IGNORES_FLARES);
87 while (iter.hasNext()) {
88 Object o = iter.next();
89 if (!(o instanceof MissileAPI) &&
91 !(o instanceof ShipAPI))
continue;
92 CombatEntityAPI other = (CombatEntityAPI) o;
93 if (other.getOwner() == owner)
continue;
95 if (other instanceof ShipAPI) {
96 ShipAPI otherShip = (ShipAPI) other;
97 if (otherShip.isHulk())
continue;
99 if (otherShip.isPhased())
continue;
102 if (other.getCollisionClass() == CollisionClass.NONE)
continue;
104 if (ignoreFlares && other instanceof MissileAPI) {
105 MissileAPI missile = (MissileAPI) other;
106 if (missile.isFlare())
continue;
109 float radius = Misc.getTargetingRadius(from, other,
false);
110 float dist = Misc.getDistance(from, other.getLocation()) - radius;
111 if (dist > range)
continue;
113 if (!Misc.isInArc(weapon.getCurrAngle(),
ARC, from, other.getLocation()))
continue;
119 if (score < minScore) {