Made wave extinguish fires / Buffed fire
This commit is contained in:
@@ -44,10 +44,11 @@ public class TurretBlocks extends BlockList implements ContentList{
|
|||||||
|
|
||||||
hail = new ArtilleryTurret("hail"){{
|
hail = new ArtilleryTurret("hail"){{
|
||||||
ammoTypes = new AmmoType[]{AmmoTypes.artilleryDense, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary};
|
ammoTypes = new AmmoType[]{AmmoTypes.artilleryDense, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary};
|
||||||
reload = 80f;
|
reload = 70f;
|
||||||
recoil = 2f;
|
recoil = 2f;
|
||||||
range = 230f;
|
range = 230f;
|
||||||
inaccuracy = 1f;
|
inaccuracy = 1f;
|
||||||
|
shootCone = 10f;
|
||||||
health = 120;
|
health = 120;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
collides = false;
|
collides = false;
|
||||||
collidesTiles = false;
|
collidesTiles = false;
|
||||||
drag = 0.03f;
|
drag = 0.03f;
|
||||||
|
hiteffect = despawneffect = Fx.none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import io.anuke.mindustry.content.fx.Fx;
|
|||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.effect.Puddle;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
@@ -30,6 +31,20 @@ public class LiquidBulletType extends BulletType{
|
|||||||
knockback = 0.5f;
|
knockback = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Bullet b) {
|
||||||
|
super.update(b);
|
||||||
|
|
||||||
|
if(liquid.canExtinguish()){
|
||||||
|
Tile tile = world.tileWorld(b.x, b.y);
|
||||||
|
if(Fire.has(tile.x, tile.y) && tile != null){
|
||||||
|
Fire.extinguish(tile, 100f);
|
||||||
|
b.remove();
|
||||||
|
hit(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Bullet b){
|
public void draw(Bullet b){
|
||||||
Draw.color(liquid.color, Color.WHITE, b.fout() / 100f + Mathf.randomSeedRange(b.id, 0.1f));
|
Draw.color(liquid.color, Color.WHITE, b.fout() / 100f + Mathf.randomSeedRange(b.id, 0.1f));
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
||||||
private static final IntMap<Fire> map = new IntMap<>();
|
private static final IntMap<Fire> map = new IntMap<>();
|
||||||
private static final float baseLifetime = 1000f;
|
private static final float baseLifetime = 1000f;
|
||||||
|
private static final float spreadChance = 0.05f, fireballChance = 0.07f;
|
||||||
|
|
||||||
private int loadedPosition = -1;
|
private int loadedPosition = -1;
|
||||||
private Tile tile;
|
private Tile tile;
|
||||||
@@ -67,6 +68,10 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean has(int x, int y){
|
||||||
|
return Mathf.inBounds(x, y, world.width(), world.height()) && map.containsKey(x + y * world.width());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to extinguish a fire by shortening its life. If there is no fire here, does nothing.
|
* Attempts to extinguish a fire by shortening its life. If there is no fire here, does nothing.
|
||||||
*/
|
*/
|
||||||
@@ -126,12 +131,12 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
|||||||
lifetime += Mathf.clamp(flammability / 8f, 0f, 0.6f) * Timers.delta();
|
lifetime += Mathf.clamp(flammability / 8f, 0f, 0.6f) * Timers.delta();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flammability > 1f && Mathf.chance(0.03 * Timers.delta() * Mathf.clamp(flammability / 5f, 0.3f, 2f))){
|
if(flammability > 1f && Mathf.chance(spreadChance * Timers.delta() * Mathf.clamp(flammability / 5f, 0.3f, 2f))){
|
||||||
GridPoint2 p = Mathf.select(Geometry.d4);
|
GridPoint2 p = Mathf.select(Geometry.d4);
|
||||||
Tile other = world.tile(tile.x + p.x, tile.y + p.y);
|
Tile other = world.tile(tile.x + p.x, tile.y + p.y);
|
||||||
create(other);
|
create(other);
|
||||||
|
|
||||||
if(Mathf.chance(0.05 * Timers.delta() * Mathf.clamp(flammability / 10.0))){
|
if(Mathf.chance(fireballChance * Timers.delta() * Mathf.clamp(flammability / 10.0))){
|
||||||
Call.createBullet(TurretBullets.fireball, x, y, Mathf.random(360f));
|
Call.createBullet(TurretBullets.fireball, x, y, Mathf.random(360f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ public class Liquid implements UnlockableContent{
|
|||||||
Liquid.liquids.add(this);
|
Liquid.liquids.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canExtinguish(){
|
||||||
|
return flammability < 0.1f && temperature <= 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
public static Array<Liquid> all(){
|
public static Array<Liquid> all(){
|
||||||
return Liquid.liquids;
|
return Liquid.liquids;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package io.anuke.mindustry.ui.fragments;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
|
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
import io.anuke.mindustry.entities.units.UnitType;
|
import io.anuke.mindustry.entities.units.UnitType;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
@@ -18,6 +20,7 @@ import io.anuke.ucore.scene.ui.Label;
|
|||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
import io.anuke.ucore.util.Log.LogHandler;
|
import io.anuke.ucore.util.Log.LogHandler;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -123,7 +126,11 @@ public class DebugFragment extends Fragment{
|
|||||||
t.row();
|
t.row();
|
||||||
t.addButton("map", () -> new GenViewDialog().show());
|
t.addButton("map", () -> new GenViewDialog().show());
|
||||||
t.row();
|
t.row();
|
||||||
t.addButton("noclip", "toggle", () -> noclip = !noclip);
|
t.addButton("fire", () -> {
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
Bullet.create(TurretBullets.fireball, player, player.x, player.y, Mathf.random(360f));
|
||||||
|
}
|
||||||
|
});
|
||||||
t.row();
|
t.row();
|
||||||
t.addButton("team", "toggle", player::toggleTeam);
|
t.addButton("team", "toggle", player::toggleTeam);
|
||||||
t.row();
|
t.row();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.world.blocks.defense.turrets;
|
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.type.AmmoType;
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
@@ -11,6 +12,9 @@ import io.anuke.mindustry.world.meta.BlockStat;
|
|||||||
import io.anuke.mindustry.world.meta.values.LiquidFilterValue;
|
import io.anuke.mindustry.world.meta.values.LiquidFilterValue;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public abstract class LiquidTurret extends Turret{
|
public abstract class LiquidTurret extends Turret{
|
||||||
protected AmmoType[] ammoTypes;
|
protected AmmoType[] ammoTypes;
|
||||||
protected ObjectMap<Liquid, AmmoType> liquidAmmoMap = new ObjectMap<>();
|
protected ObjectMap<Liquid, AmmoType> liquidAmmoMap = new ObjectMap<>();
|
||||||
@@ -27,6 +31,33 @@ public abstract class LiquidTurret extends Turret{
|
|||||||
stats.add(BlockStat.inputLiquid, new LiquidFilterValue(item -> liquidAmmoMap.containsKey(item)));
|
stats.add(BlockStat.inputLiquid, new LiquidFilterValue(item -> liquidAmmoMap.containsKey(item)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateTarget(Tile tile) {
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
if(entity.liquids.current().canExtinguish() && entity.target instanceof Tile){
|
||||||
|
return Fire.has(((Tile) entity.target).x, ((Tile) entity.target).y);
|
||||||
|
}
|
||||||
|
return super.validateTarget(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void findTarget(Tile tile) {
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
if(entity.liquids.current().canExtinguish()){
|
||||||
|
int tr = (int)(range / tilesize);
|
||||||
|
for (int x = -tr; x <= tr; x++) {
|
||||||
|
for (int y = -tr; y <= tr; y++) {
|
||||||
|
if(Fire.has(x + tile.x, y + tile.y)){
|
||||||
|
entity.target = world.tile(x + tile.x, y + tile.y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.findTarget(tile);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
super.setBars();
|
super.setBars();
|
||||||
|
|||||||
@@ -190,11 +190,10 @@ public abstract class Turret extends Block{
|
|||||||
if(hasAmmo(tile)){
|
if(hasAmmo(tile)){
|
||||||
|
|
||||||
if(entity.timer.get(timerTarget, targetInterval)){
|
if(entity.timer.get(timerTarget, targetInterval)){
|
||||||
entity.target = Units.getClosestTarget(tile.getTeam(),
|
findTarget(tile);
|
||||||
tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Units.invalidateTarget(entity.target, tile.getTeam(), tile.drawx(), tile.drawy())){
|
if(validateTarget(tile)){
|
||||||
|
|
||||||
AmmoType type = peekAmmo(tile);
|
AmmoType type = peekAmmo(tile);
|
||||||
float speed = type.bullet.speed;
|
float speed = type.bullet.speed;
|
||||||
@@ -222,6 +221,18 @@ public abstract class Turret extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean validateTarget(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
return !Units.invalidateTarget(entity.target, tile.getTeam(), tile.drawx(), tile.drawy());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void findTarget(Tile tile){
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
entity.target = Units.getClosestTarget(tile.getTeam(),
|
||||||
|
tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean shouldTurn(Tile tile){
|
public boolean shouldTurn(Tile tile){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user