Two mod bug questions:
- LazyLib contains this method:
Spoiler
/**
* Spawns a ship directly onto the battle map, bypassing the fleet reserves.
*
* <b>NOTE: this method will not work out of the box in the campaign (.6.2a)
* due to an after-battle crash in the default FleetEncounterContextPlugin
* caused by spawned ships not being registered with the fleet.</b>
*
* @param variantId The ID of the ship variant to spawn.
* @param type Whether this is a ship or a fighter wing.
* @param side What side of the battle this ship should fight on.
* @param combatReadiness The CR the ship should start with.
* @param location The location on the battle map the ship should
* spawn at.
* @param facing The initial facing of the ship on the battle map.
*
* @return The {@link ShipAPI} that was spawned by this method.
*
* @since 1.9
*/
public static ShipAPI spawnShipOrWingDirectly(String variantId,
FleetMemberType type, FleetSide side, float combatReadiness,
Vector2f location, float facing)
{
FleetMemberAPI member = Global.getFactory().createFleetMember(type, variantId);
member.getCrewComposition().addCrew(member.getNeededCrew());
ShipAPI ship = Global.getCombatEngine().getFleetManager(side)
.spawnFleetMember(member, location, facing, 0f);
ship.setCRAtDeployment(combatReadiness);
ship.setCurrentCR(combatReadiness);
ship.setOwner(side.ordinal());
ship.getShipAI().forceCircumstanceEvaluation();
return ship;
}
Example usage:
runcode CombatUtils.spawnShipOrWingDirectly("mudskipper_Hull", FleetMemberType.SHIP, FleetSide.ENEMY, 0.7f, new Vector2f(0, 0), 0);
Here's the thing: I can use this to spawn a ship on the enemy side, as per the above console command. But when it dies, the "<shipname> disabled" message in the top-left uses the green color of friendly ships. Is this a bug in the base game's combat engine?
-
Could this bug be looked at? I realize it's a pretty rare issue specific to particular mod circumstances, but the crash log indicates it's happening within base game code.
A question I have to ask again - sounds control.
Any way to check if a sound is currently playing, or if it finished playing?
I have a weapon that I have to control fully trough scripts, including sounds - and while the warmup and powerdown are simple (just check in which charge state I am, play it and set a boolean so it's not triggered again on next frame update), but fire does not have a 100% set duration (it has a maximum, but it can be shorter), so the sound has to be looped.
Right now it just keeps getting re-started every frame, so it sounds bad.
Doesn't seem like the sound player API has a way to do that.
Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.