Probably, I have no idea cuz I've never done java or any other development work for that matter. I'm just trying to put together bits and pieces from what I can find and see if things work out.
Anyway, here is a ship system which reflects all incoming projectiles right back and possibly hit their source. but for some reason, it only works in simulation and doesn't work in actual combat.
Caused by: org.codehaus.commons.compiler.CompileException: File data/shipsystems/scripts/cheatsystem.java, Line 55, Column 19: No applicable constructor/method found for actual parameters "java.lang.String"; candidates are: "public abstract void com.fs.starfarer.api.combat.DamagingProjectileAPI.setSource(com.fs.starfarer.api.combat.ShipAPI)"
ShipAPI ship = CombatUtils.getOwner(stats);
int owner = ship.getOwner();
Vector2f velocity;
float facing;
DamagingProjectileAPI proj;
for (Iterator iter = CombatUtils.getCombatEngine().getProjectiles().iterator();
iter.hasNext()
//CombatUtils is just a plugin from another mod, this thing just calls for all the units in combat I think {
proj = (DamagingProjectileAPI) iter.next();
if (proj.getOwner() == ship.getOwner())
{
// Don't affect friendly projectiles continue;
}
if (CombatUtils.getDistance(proj, ship) > 280f)
{
// Ignore projectiles that are out of range of the field continue;
}
velocity = proj.getVelocity();
velocity.set(velocity.x*-1,velocity.y*-1);
facing = proj.getFacing();
proj.setFacing(facing +180);
// send back the way they came proj.setOwner(owner);
//making me the owner will make missiles start to seek enemy targets. proj.setSource(ship);
// this setSource is what gives problems. I think there is some problem with getting the source of projectiles in real combat with pirates. }
Also, is it possible to make this a hullmod instead of ship system?
and how would I make a system that will prevent all AI ships from retreating? I think it would be very similar to this, I'm just asking since I always get the syntax wrong.