Mass driver bullets are destroyed like the blocks with items (#10969)

* Mass driver bullets explosions like the blocks

* Better code style

---------

Co-authored-by: TempUser <temp@mail>
This commit is contained in:
Agzam4 2025-06-27 01:51:16 +03:00 committed by GitHub
parent 34032f63a5
commit b7cb080f36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -4,8 +4,10 @@ import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.blocks.distribution.MassDriver.*;
import static mindustry.Vars.*;
@ -89,5 +91,17 @@ public class MassDriverBolt extends BasicBulletType{
public void hit(Bullet b, float hitx, float hity){
super.hit(b, hitx, hity);
despawned(b);
if(b.data() instanceof DriverBulletData data){
float explosiveness = 0f;
float flammability = 0f;
float power = 0f;
for(int i = 0; i < data.items.length; i++){
Item item = content.item(i);
explosiveness += item.explosiveness * data.items[i];
flammability += item.flammability * data.items[i];
power += item.charge * Mathf.pow(data.items[i], 1.1f) * 25f;
}
Damage.dynamicExplosion(b.x, b.y, flammability / 10f, explosiveness / 10f, power, 1f, state.rules.damageExplosions);
}
}
}

View file

@ -299,7 +299,7 @@ public class MassDriver extends Block{
bullet.create(this, team,
x + Angles.trnsx(angle, translation), y + Angles.trnsy(angle, translation),
angle, -1f, bulletSpeed, bulletLifetime, data);
angle, totalUsed/2f, bulletSpeed, bulletLifetime, data);
shootEffect.at(x + Angles.trnsx(angle, translation), y + Angles.trnsy(angle, translation), angle);
smokeEffect.at(x + Angles.trnsx(angle, translation), y + Angles.trnsy(angle, translation), angle);