What is the best way to play a sound from a ship when a shipsystem is activated?
I tried inside of the BaseShipSystemScript class but can't seem to find the right hooks.
For example, I tried:
public float getInfoText(ShipSystemAPI system, ShipAPI ship)
{
Global.getSoundPlayer().playSound("waaagh", 1f, .8f, ship.getLocation(), new Vector2f());
return 0f;
}
I tried something that would use the shipapi, therefore I could use ship.location. Had no success so far. Is there a simpler command inside of the BaseShipSystemScript class?
Current shipsystem code with commented out part:
Spoiler
package data.shipsystems.scripts;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.Global;
//import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.impl.combat.BaseShipSystemScript;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import org.lwjgl.util.vector.Vector2f;
public class WaaaghStats extends BaseShipSystemScript {
public static final float ROF_BONUS = 1f;
public static final float FLUX_REDUCTION = 50f;
/*
public float getInfoText(ShipSystemAPI system, ShipAPI ship)
{
Global.getSoundPlayer().playSound("waaagh", 1f, .8f, ship.getLocation(), new Vector2f());
return 0f;
}
*/
public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
{
if (state == ShipSystemStatsScript.State.OUT) {
stats.getMaxSpeed().unmodify(id); // to slow down ship to its regular top speed while powering drive down
} else {
stats.getMaxSpeed().modifyFlat(id, 200f * effectLevel);
stats.getAcceleration().modifyFlat(id, 200f * effectLevel);
//stats.getAcceleration().modifyPercent(id, 200f * effectLevel);
}
float mult = 1f + ROF_BONUS * effectLevel;
stats.getBallisticRoFMult().modifyMult(id, mult);
stats.getBallisticWeaponFluxCostMod().modifyMult(id, 1f - (FLUX_REDUCTION * 0.01f));
}
public void unapply(MutableShipStatsAPI stats, String id)
{
stats.getMaxSpeed().unmodify(id);
stats.getMaxTurnRate().unmodify(id);
stats.getTurnAcceleration().unmodify(id);
stats.getAcceleration().unmodify(id);
stats.getDeceleration().unmodify(id);
stats.getBallisticRoFMult().unmodify(id);
stats.getBallisticWeaponFluxCostMod().unmodify(id);
}
public StatusData getStatusData(int index, State state, float effectLevel) {
float mult = 1f + ROF_BONUS * effectLevel;
float bonusPercent = (int) ((mult - 1f) * 100f);
if (index == 0)
{
return new StatusData("ballistic rate of fire +" + (int) bonusPercent + "%", false);
//return new StatusData("increased engine power", false);
}
if (index == 1)
{
return new StatusData("ballistic flux use -" + (int) FLUX_REDUCTION + "%", false);
}
return null;
}
}
Also, what is the correct way to return more then one StatusData at the same time?