Alright so, for those who dont know, ive been working on a mod for SC2, that means, creating a few mechanics that arent present in the vanilla.
Right now im stuck with a weapon i cant manage to work, know as the Variable power blaster.
It spawns a projectile infront of the ship, that projectile can be used as a shield and its consumed if used like that, but, the more time you charge the weapon, the stronger that projectile gets. The weapon has 4 stages, a green one that does 2000 dmg, next comes the blue does 4000 dmg, then the purple/magenta, does 8000 damage and last comes the red one doing 16000 damage. While the projectile with stay still as long as you keep "firing", meaning holding the LMB, when you release, it will release the projectile that was currently created. While i cant make the weapon permanently chargeable, ive been trying to at list do the projectile animation infront of the ship and once you released the charge it would reset the animation and would spawn the projectile for the current charge level.
So far the weapon plugin i worked on with Lazy's help has ignored every condition i/he set to avoid spawning projectiles with 0 cd.
package data.scripts.plugins;
import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import java.awt.Color;
public class TraderVariablePowerBlasterEffect implements EveryFrameWeaponEffectPlugin
{
// weapon takes 7 seconds to fully charge
private int currentCharge = 0;
private float currentChargelvl = 0;
public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
{
ShipAPI ship = weapon.getShip();
if (ship == null)
{
return;
}
currentChargelvl = weapon.getChargeLevel();
AnimationAPI animation = weapon.getAnimation();
if (weapon.isFiring())
{
ship.getMutableStats().getFluxDissipation().modifyFlat(ship.getHullSpec().getHullId().toString(), 0); //while chargins the dissipation should be set to 0
if (currentChargelvl <= 0.33f)
{
//Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
if(currentCharge == 0)
{
engine.addFloatingText(ship.getLocation(), "Power Level 1",25f,Color.GREEN,weapon.getShip(),0f,0f);
currentCharge = 1;
animation.setFrame(1);
animation.play();
}
if(animation.getFrame() == 5)
{
animation.setFrame(1);
animation.play();
}
}
if (currentChargelvl <= 0.66f && currentChargelvl > 0.33f)
{
if(currentCharge == 1)
{
Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
engine.addFloatingText(ship.getLocation(), "Power Level 2",25f,Color.BLUE,weapon.getShip(),0f,0f);
currentCharge = 2;
animation.setFrame(6);
animation.play();
}
if(animation.getFrame() == 10)
{
animation.setFrame(6);
animation.play();
}
}
if (currentChargelvl <= 0.99f && currentChargelvl > 0.66f)
{
if(currentCharge == 2)
{
Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
currentCharge = 3;
animation.setFrame(11);
animation.play();
}
if(animation.getFrame() == 15)
{
animation.setFrame(11);
animation.play();
}
}
if(currentChargelvl > 0.99f)
{
if(currentCharge == 3)
{
engine.addFloatingText(ship.getLocation(), "Max Power Level",25f,Color.RED,weapon.getShip(),0f,0f);
currentCharge = 4;
animation.setFrame(16);
animation.play();
}
if(animation.getFrame() == 20)
{
animation.setFrame(16);
animation.play();
}
}
}
else
{
switch (currentCharge)
{
case 1:
{
Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
ship.getFluxTracker().increaseFlux(500, false);
weapon.setRemainingCooldownTo(1f);
break;
}
case 2:
{
Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
ship.getFluxTracker().increaseFlux(500, false);
weapon.setRemainingCooldownTo(1f);
break;
}
case 3:
{
Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
ship.getFluxTracker().increaseFlux(500, false);
weapon.setRemainingCooldownTo(1f);
break;
}
default:
// Whatever happens if it isn't charged
}
ship.getMutableStats().getFluxDissipation().unmodify();
currentCharge = 0;
}
}//advance
}
With the code atm, will spawn the lvl 1 projectile without charging anything.