Integrated new laser damage computation
Fixed CME Fixed crash when no entity was in sight Fixed damage level towards entities
This commit is contained in:
parent
564b6d968e
commit
940c803e8a
2 changed files with 40 additions and 38 deletions
|
@ -223,45 +223,47 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced {
|
|||
}
|
||||
|
||||
// Apply effect to entities
|
||||
for (Entry<Double, MovingObjectPosition> entityHitEntry : entityHits.entrySet()) {
|
||||
double entityHitDistance = entityHitEntry.getKey();
|
||||
// ignore entities behind walls
|
||||
if (entityHitDistance >= blockHitDistance) {
|
||||
break;
|
||||
}
|
||||
|
||||
// only hits entities with health
|
||||
MovingObjectPosition mopEntity = entityHitEntry.getValue();
|
||||
if (mopEntity != null && mopEntity.entityHit instanceof EntityLivingBase) {
|
||||
EntityLivingBase entity = (EntityLivingBase) mopEntity.entityHit;
|
||||
|
||||
// Consume energy
|
||||
energy -= WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY
|
||||
+ ((blockHitDistance - distanceTravelled) * WarpDriveConfig.LASER_CANNON_ENERGY_LOSS_PER_BLOCK);
|
||||
distanceTravelled = blockHitDistance;
|
||||
vHitPoint = new Vector3(mopEntity.hitVec);
|
||||
if (energy <= 0) {
|
||||
if (entityHits != null) {
|
||||
for (Entry<Double, MovingObjectPosition> entityHitEntry : entityHits.entrySet()) {
|
||||
double entityHitDistance = entityHitEntry.getKey();
|
||||
// ignore entities behind walls
|
||||
if (entityHitDistance >= blockHitDistance) {
|
||||
break;
|
||||
}
|
||||
|
||||
// apply effects
|
||||
entity.setFire(WarpDriveConfig.LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS);
|
||||
float damage = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_MAX_DAMAGE,
|
||||
WarpDriveConfig.LASER_CANNON_ENTITY_HIT_BASE_DAMAGE + energy / WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE);
|
||||
entity.attackEntityFrom(DamageSource.inFire, damage);
|
||||
// only hits entities with health
|
||||
MovingObjectPosition mopEntity = entityHitEntry.getValue();
|
||||
if (mopEntity != null && mopEntity.entityHit instanceof EntityLivingBase) {
|
||||
EntityLivingBase entity = (EntityLivingBase) mopEntity.entityHit;
|
||||
|
||||
if (energy > WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY_THRESHOLD_FOR_EXPLOSION) {
|
||||
float strength = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH,
|
||||
WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_BASE_STRENGTH + energy / WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_ENERGY_PER_STRENGTH);
|
||||
worldObj.newExplosion(null, entity.posX, entity.posY, entity.posZ, strength, true, true);
|
||||
// Consume energy
|
||||
energy -= WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY
|
||||
+ ((blockHitDistance - distanceTravelled) * WarpDriveConfig.LASER_CANNON_ENERGY_LOSS_PER_BLOCK);
|
||||
distanceTravelled = blockHitDistance;
|
||||
vHitPoint = new Vector3(mopEntity.hitVec);
|
||||
if (energy <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// apply effects
|
||||
entity.setFire(WarpDriveConfig.LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS);
|
||||
float damage = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_MAX_DAMAGE,
|
||||
WarpDriveConfig.LASER_CANNON_ENTITY_HIT_BASE_DAMAGE + energy / WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE);
|
||||
entity.attackEntityFrom(DamageSource.inFire, damage);
|
||||
|
||||
if (energy > WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY_THRESHOLD_FOR_EXPLOSION) {
|
||||
float strength = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH,
|
||||
WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_BASE_STRENGTH + energy / WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_ENERGY_PER_STRENGTH);
|
||||
worldObj.newExplosion(null, entity.posX, entity.posY, entity.posZ, strength, true, true);
|
||||
}
|
||||
|
||||
// remove entity from hit list
|
||||
entityHits.put(entityHitDistance, null);
|
||||
}
|
||||
|
||||
// remove entity from hit list
|
||||
entityHits.remove(entityHitDistance);
|
||||
}
|
||||
}
|
||||
if (energy <= 0) {
|
||||
break;
|
||||
if (energy <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Laser went too far or no block hit
|
||||
|
|
|
@ -196,9 +196,9 @@ public class WarpDriveConfig {
|
|||
public static int LASER_CANNON_ENERGY_LOSS_PER_BLOCK = 500;
|
||||
|
||||
public static int LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS = 100;
|
||||
public static int LASER_CANNON_ENTITY_HIT_ENERGY = 0;
|
||||
public static int LASER_CANNON_ENTITY_HIT_BASE_DAMAGE = 1;
|
||||
public static int LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE = 10000;
|
||||
public static int LASER_CANNON_ENTITY_HIT_ENERGY = 15000;
|
||||
public static int LASER_CANNON_ENTITY_HIT_BASE_DAMAGE = 3;
|
||||
public static int LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE = 30000;
|
||||
public static int LASER_CANNON_ENTITY_HIT_MAX_DAMAGE = 100;
|
||||
|
||||
public static int LASER_CANNON_ENTITY_HIT_ENERGY_THRESHOLD_FOR_EXPLOSION = 1000000;
|
||||
|
@ -670,7 +670,7 @@ public class WarpDriveConfig {
|
|||
LASER_CANNON_ENTITY_HIT_ENERGY = clamp(0, LASER_CANNON_MAX_LASER_ENERGY,
|
||||
config.get("laser_cannon", "entity_hit_energy", LASER_CANNON_ENTITY_HIT_ENERGY, "Base energy consumed from hitting an entity").getInt());
|
||||
LASER_CANNON_ENTITY_HIT_BASE_DAMAGE = clamp(0, LASER_CANNON_MAX_LASER_ENERGY,
|
||||
config.get("laser_cannon", "entity_hit_base_damage", LASER_CANNON_ENTITY_HIT_BASE_DAMAGE, "Minimum damage to entity hit").getInt());
|
||||
config.get("laser_cannon", "entity_hit_base_damage", LASER_CANNON_ENTITY_HIT_BASE_DAMAGE, "Minimum damage to entity hit (measured in half hearts)").getInt());
|
||||
LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE = clamp(0, LASER_CANNON_MAX_LASER_ENERGY,
|
||||
config.get("laser_cannon", "entity_hit_energy_per_damage", LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE, "Energy required by additional hit point (won't be consummed)").getInt());
|
||||
LASER_CANNON_ENTITY_HIT_MAX_DAMAGE = clamp(0, Integer.MAX_VALUE,
|
||||
|
|
Loading…
Reference in a new issue