(Sorry for the delay!)
Hmm, that's not really enough info. What's "inconsistently", vs what are your expectations? It would also help to see your code - or, rather, a minimal snippet that produces the behavior.
Hi, and no worries! Here's a video of what im talking about
https://imgur.com/a/9OSiZ7eYou can see the first time I shoot, I think all the bullets spawn correctly. But the next time I use the system, only one bullet is spawned in while firing.
So I have a weapon that fires a burst of 8 shots. The ship this issue is on has a system that replaces these shots with a stronger version of them.
To prevent bullets appearing when they shouldn't, I added (if(weapon.getCooldownRemaining() <= 0)) as a condition, which works flawlessly..or almost always, anyway. BUT when time dilation effect is active, sometimes bullets will spawn, and sometimes they wont.
Puretilt actually helped me with this, because he had a similar issue, and well, I will post my code, and then the conclusion he came to. This is in an every frame weapon effect script.
@Override
public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
for (DamagingProjectileAPI proj : engine.getProjectiles())
{
//if this is one of our projectiles and hasn't been accounted for
if (weapon == proj.getWeapon() && !registeredProjectiles.contains(proj) && !explodingProjectiles.contains(proj))
{
//add it (prevent infinite bullet works)
registeredProjectiles.add(proj);
//If the weapon can actually fire
if(weapon.getCooldownRemaining() <= 0)
{
FluxTrackerAPI fluxLevel = weapon.getShip().getFluxTracker();
//Spawn the new projectile
DamagingProjectileAPI newProj = (DamagingProjectileAPI) engine.spawnProjectile(ship, weapon, "armaa_einhanderGun2", proj.getLocation(), proj.getFacing(), ship.getVelocity());
if(fluxLevel.getCurrFlux()+weapon.getFluxCostToFire() > fluxLevel.getMaxFlux())
{
fluxLevel.forceOverload(0f);
}
else
fluxLevel.setCurrFlux(fluxLevel.getCurrFlux()+weapon.getFluxCostToFire());
//ad the new proj for fx stuff later
explodingProjectiles.add(newProj);
Global.getSoundPlayer().playSound("plasma_cannon_fire", 1f, 0.7f, newProj.getLocation(), newProj.getVelocity());
}
//remove old bullet
Global.getCombatEngine().removeEntity(proj);
}
}
}
I don't 100% remember the specifics of the issue now, but it seemed like there is a delay with spawning bullets under time dilation? What tilt did was add a 2 frame delay to his script, which fixed his issue, but I just disabled being able to use this specific ships right click to get around it for the time being