Sometesting of the code shows that
particleVelocity.x = ((float) Math.random() * 10f); //give the particle a random velocity.
particleVelocity.y = ((float) Math.random() * 10f); //Math.random() results in a number between 0.0 and 1.0
are causeing the problems. As for the corect code? not sure ill look into it.
Oh also the damage spawning line of code, you had "engine" as the source of the damage. I changed that to projectile.getSource(), dont know if that has any relevance though as it didnt fix the problem till i got rid of the .x .y lines of code.
EDIT*
After some testing i got the code to work... as for why? i dont know. Maybe its because i set up the particalVelocity vairable useing getVelocity()... not idea. Well:
heres what i used that worked without error:
package data.scripts.weapons;
import java.awt.Color;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
public class ExtraHitEffect implements OnHitEffectPlugin {
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
if (!shieldHit && target instanceof ShipAPI)
{
//set vairables for the partical. Could do inside the call but will do it here
float particleSize = 15f;
float particleBrightness = 1f;
float particleDuration = 2f;
Color particleColor = new Color(85, 25, 215, 255);
Vector2f particleVelocity = projectile.getVelocity(); // Lines below were causing issues, so i replaced them for testing
particleVelocity.x = ((float) Math.random() * 10f); //give the particle a random velocity.
particleVelocity.y = ((float) Math.random() * 10f); //Math.random() results in a number between 0.0 and 1.0
//set damage vairables
float damageAmount = projectile.getDamageAmount() * .25f; //extra damage is 1/4 of full
float empAmount = projectile.getEmpAmount(); //extra emp is... well full amount of normal hit
engine.applyDamage(target, point, damageAmount, DamageType.ENERGY, empAmount, false, false, projectile.getSource());
engine.addHitParticle(point, particleVelocity, particleSize, particleBrightness, particleDuration, particleColor);
//soundToPlay.playSound(soundName, pitch, volume, point, particleVelocity);
}
}
}
Also, anyone able to take a look at my question earlier yet?
http://fractalsoftworks.com/forum/index.php?topic=5061.msg85513#msg85513