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