@SwissArmyKnife: not actually sure offhand what's going on. Might be another error message somewhere earlier in the log? This sort of thing might happen if your script is doing something Janino (the compiler the game uses for loose scripts) doesn't support, or if the class doesn't have a default constructor, but none of that seems to be the problem in your code.
Thanks for taking a look at it. This may be a dumb question but I couldn't find a good answer anywhere and it's making me think the solution is simpler than it seems.
If I want to add a .java file to an existing mod's .jar file. For instance adding my new guns animation .java file to DiableAvionics .jar file. How do I do that? Do I need to use something like netbeans to package and compile the whole thing again from src?
Do I even need to do that in the first place?
Update: Figured it out! Not ideally but it works which is good enough for a small personal mod. Ended up putting the java file in Diable's data/scripts/weapons instead of trying to add into into it's jar file.
Now my only issue is getting it to animate properly. Right now it's just cycling through the frames over and over. I need it to pause on frame 5 during firing but I'm not sure how to do that. I have no real idea what I'm doing so I looked at a bunch of different guns and couldn't find one that did the above.
I assumed that if (!weapon.isFiring()) would dicate what it was doing while firing but adding animeSetFrame(5); in there just locks it to frame 5 in it's resting state. Firing animation still cycles through all 13 on a loop.
Here's the anim code again.
Spoiler
// By Deathfly
package data.scripts.weapons;
import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
public class EldosAnimation implements EveryFrameWeaponEffectPlugin {
private final float validFrames = 13;
// private final float animeMAXchargelvl = 0.8f;
private float chargeLevel = 0;
@Override
public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
AnimationAPI anime = weapon.getAnimation();
if (anime == null){
return;
}
if (!weapon.isFiring()) {
chargeLevel = 0;
anime.setFrameRate(-12);
if (anime.getFrame() == 0) {
anime.setFrameRate(0);
}
} else {
if (weapon.getChargeLevel() >= chargeLevel) {
chargeLevel = weapon.getChargeLevel();
if (anime.getFrame() < validFrames) {
anime.setFrameRate(12);
} else {
anime.setFrameRate(0);
anime.setFrame(13);
}
} else {
chargeLevel = weapon.getChargeLevel();
if (anime.getFrame() > 0) {
anime.setFrameRate(-12);
} else {
anime.setFrameRate(0);
anime.setFrame(0);
}
}
if (weapon.getShip().getFluxTracker().isOverloadedOrVenting()){
weapon.setRemainingCooldownTo(weapon.getCooldown());
}
}
}
}