Knockback following bullet direction (#5313)
This commit is contained in:
@@ -56,6 +56,8 @@ public abstract class BulletType extends Content{
|
||||
public float splashDamage = 0f;
|
||||
/** Knockback in velocity. */
|
||||
public float knockback;
|
||||
/** Should knockback the bullet's direction */
|
||||
public boolean impact;
|
||||
/** Status effect applied on hit. */
|
||||
public StatusEffect status = StatusEffects.none;
|
||||
/** Intensity of applied status effect in terms of duration. */
|
||||
@@ -191,7 +193,9 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
if(entity instanceof Unit unit){
|
||||
unit.impulse(Tmp.v3.set(unit).sub(b.x, b.y).nor().scl(knockback * 80f));
|
||||
Tmp.v3.set(unit).sub(b.x, b.y).nor().scl(knockback * 80f);
|
||||
if(impact) Tmp.v3.setAngle(b.rotation());
|
||||
unit.impulse(Tmp.v3);
|
||||
unit.apply(status, statusDuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ContinuousLaserBulletType extends BulletType{
|
||||
incendSpread = 5;
|
||||
incendChance = 0.4f;
|
||||
lightColor = Color.orange;
|
||||
impact = true;
|
||||
keepVelocity = false;
|
||||
collides = false;
|
||||
pierce = true;
|
||||
|
||||
@@ -30,6 +30,7 @@ public class LaserBulletType extends BulletType{
|
||||
smokeEffect = Fx.none;
|
||||
hitSize = 4;
|
||||
lifetime = 16f;
|
||||
impact = true;
|
||||
keepVelocity = false;
|
||||
collides = false;
|
||||
pierce = true;
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SapBulletType extends BulletType{
|
||||
hitEffect = Fx.hitLiquid;
|
||||
status = StatusEffects.sapped;
|
||||
statusDuration = 60f * 3f;
|
||||
impact = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user