diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 3c774dde32..6c0da0435a 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -161,6 +161,8 @@ public class BulletType extends Content implements Cloneable{ public float healPercent = 0f; /** flat amount of block health healed */ public float healAmount = 0f; + /** Fraction of bullet damage that heals that shooter. */ + public float lifesteal = 0f; /** Whether to make fire on impact */ public boolean makeFire = false; /** Whether this bullet will always hit blocks under it. */ @@ -450,6 +452,10 @@ public class BulletType extends Content implements Cloneable{ }else{ health += shield; } + if(lifesteal > 0f && b.owner instanceof Healthc o){ + float result = Math.max(Math.min(h.health(), damage), 0); + o.heal(result * lifesteal); + } if(pierceArmor){ h.damagePierce(damage); }else{ diff --git a/core/src/mindustry/logic/LAssembler.java b/core/src/mindustry/logic/LAssembler.java index 2d6b214386..4995bb7e89 100644 --- a/core/src/mindustry/logic/LAssembler.java +++ b/core/src/mindustry/logic/LAssembler.java @@ -35,7 +35,7 @@ public class LAssembler{ Seq st = read(data, privileged); asm.privileged = privileged; - + asm.instructions = st.map(l -> l.build(asm)).retainAll(l -> l != null).toArray(LInstruction.class); return asm; } @@ -74,7 +74,7 @@ public class LAssembler{ symbol = symbol.replace(' ', '_'); //use a positive invalid number if number might be negative, else use a negative invalid number - int usedInvalidNum = symbol.startsWith("-") ? invalidNumPositive : invalidNumNegative; + int usedInvalidNum = symbol.length() > 0 && symbol.charAt(0) == '-' ? invalidNumPositive : invalidNumNegative; double value = parseDouble(symbol, usedInvalidNum); if(value == usedInvalidNum){