I'm trying to take the large cannon from Black Rock Driveyards, Solenoid, and turn it into a big old Diable flavored beam cannon. This would be easy enough but I want to retain it's animations, with it opening up on start up, freezing on say frame 4 during firing, then progressing to the end on cooldown. I'm in the weeds since beam weapons .wpn file works a little differently than projectile .wpn files do.
The sprites are easy enough but I'm unsure how the animation is handled. The original Solenoid .wpn file had lines for numFrames and framerate, and it's animtype set to MUZZLE_FLASH. Can beam weapons have muzzle flash, let alone sprite based animations? I couldn't find a vanilla example, the most indepth those got were recoil or glow effects.
I'm also not really sure what the everyFrameEffect and .java file do. I again based mine off the original Solenoid and guessed what the file was doing.
Sprites (Still need to do the turret version I know):
.wpn
Spoiler
{
"id":"diableavionics_eldos", # this id must match what's in the spreadsheet
"specClass":"beam",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":1200,
"turretSprite":"graphics/da/weapons/eldos/eldos_turret00.png",
"hardpointSprite":"graphics/da/weapons/eldos/eldos_hpbarrel00.png",
"numFrames":24,
"frameRate":15,
"visualRecoil":0.0, # the gun sprites are only used if this is non-0
"renderHints":[RENDER_BARREL_BELOW],
"turretOffsets":[30, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[50, 0],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED. whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH", # NONE, GLOW, MUZZLE_FLASH, SMOKE
"muzzleFlashSpec":{"length":45.0, # only used if animationType = MUZZLE_FLASH
"spread":6.0,
"particleSizeMin":1.0,
"particleSizeRange":60.0,
"particleDuration":1.25,
"particleCount":63,
"particleColor":[135,155,170,125]},
"fireSoundOne":"diableavionics_eldos_start",
"fireSoundTwo":"diableavionics_eldos_loop",
"everyFrameEffect":"data.scripts.weapons.EldosAnimation",
}
EldosAnimation.java
Spoiler
package data.scripts.weapons;
public class EldosAnimation extends BaseAnimateOnFireEffect {
public EldosAnimation() {
super(); // doesn't actually do anything
setFramesPerSecond(15);
pauseOnFrame(4);
}
}
Thanks!
Update: Figured out most of the above by copying some stuff from Neutrino Corps Phase Cannon. Only issue now is the java file crashes Starsector on load with:
Spoiler
java.lang.RuntimeException: Error compiling [data.scripts.weapons.EldosAnimation]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.weapons.EldosAnimation
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
And here's the java file.
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());
}
}
}
}
I figured it was because the default compiler runs JDK 6 and I need JDK 7 but all the IDE guides I found were massively out of date. Tried IntelliJ IDEA and couldn't for the life of me get it to actually compile the damn jar file. Giving up until tomorrow.