New WIP achievement definitions

This commit is contained in:
Anuken
2022-10-09 17:47:12 -04:00
parent dfdb4c1c1f
commit 4201106843
20 changed files with 419 additions and 26 deletions
+17 -8
View File
@@ -19,6 +19,7 @@ import static mindustry.Vars.*;
/** Utility class for damaging in an area. */
public class Damage{
private static final UnitDamageEvent bulletDamageEvent = new UnitDamageEvent();
private static final Rect rect = new Rect();
private static final Rect hitrect = new Rect();
private static final Vec2 vec = new Vec2(), seg1 = new Vec2(), seg2 = new Vec2();
@@ -467,21 +468,29 @@ public class Damage{
/** Damages all entities and blocks in a radius that are enemies of the team. */
public static void damage(Team team, float x, float y, float radius, float damage, boolean complete, boolean air, boolean ground, boolean scaled, @Nullable Bullet source){
Cons<Unit> cons = entity -> {
if(entity.team == team || !entity.checkTarget(air, ground) || !entity.hittable() || !entity.within(x, y, radius + (scaled ? entity.hitSize / 2f : 0f))){
Cons<Unit> cons = unit -> {
if(unit.team == team || !unit.checkTarget(air, ground) || !unit.hittable() || !unit.within(x, y, radius + (scaled ? unit.hitSize / 2f : 0f))){
return;
}
float amount = calculateDamage(scaled ? Math.max(0, entity.dst(x, y) - entity.type.hitSize/2) : entity.dst(x, y), radius, damage);
entity.damage(amount);
boolean dead = unit.dead;
float amount = calculateDamage(scaled ? Math.max(0, unit.dst(x, y) - unit.type.hitSize/2) : unit.dst(x, y), radius, damage);
unit.damage(amount);
if(source != null){
entity.controller().hit(source);
Events.fire(bulletDamageEvent.set(unit, source));
unit.controller().hit(source);
if(!dead && unit.dead){
Events.fire(new UnitBulletDestroyEvent(unit, source));
}
}
//TODO better velocity displacement
float dst = vec.set(entity.x - x, entity.y - y).len();
entity.vel.add(vec.setLength((1f - dst / radius) * 2f / entity.mass()));
float dst = vec.set(unit.x - x, unit.y - y).len();
unit.vel.add(vec.setLength((1f - dst / radius) * 2f / unit.mass()));
if(complete && damage >= 9999999f && entity.isPlayer()){
if(complete && damage >= 9999999f && unit.isPlayer()){
Events.fire(Trigger.exclusionDeath);
}
};