Use target lifetime rather than construct lifetime when dealing periodic damage; means targets don't all get damaged at once

This commit is contained in:
Electroblob77
2020-01-25 22:50:45 +00:00
parent 40e77728ad
commit 6cd6411c25
3 changed files with 25 additions and 27 deletions
@@ -65,7 +65,7 @@ public class EntityBubble extends EntityMagicConstruct {
if(isDarkOrb){ if(isDarkOrb){
if(WizardryUtilities.getRider(this) != null if(WizardryUtilities.getRider(this) != null
&& this.ticksExisted % Spells.entrapment.getProperty(Entrapment.DAMAGE_INTERVAL).intValue() == 0){ && WizardryUtilities.getRider(this).ticksExisted % Spells.entrapment.getProperty(Entrapment.DAMAGE_INTERVAL).intValue() == 0){
if(this.getCaster() != null){ if(this.getCaster() != null){
WizardryUtilities.getRider(this).attackEntityFrom( WizardryUtilities.getRider(this).attackEntityFrom(
MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC),
@@ -80,8 +80,8 @@ public class EntityHammer extends EntityMagicConstruct {
if(this.world.isRemote && this.ticksExisted % 3 == 0){ if(this.world.isRemote && this.ticksExisted % 3 == 0){
ParticleBuilder.create(Type.SPARK) ParticleBuilder.create(Type.SPARK)
.pos(this.posX - 0.5d + rand.nextDouble(), this.posY + 2 * rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble()) .pos(this.posX - 0.5d + rand.nextDouble(), this.posY + 2 * rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble())
.spawn(world); .spawn(world);
} }
this.prevPosX = this.posX; this.prevPosX = this.posX;
@@ -103,39 +103,37 @@ public class EntityHammer extends EntityMagicConstruct {
this.rotationPitch = 0; this.rotationPitch = 0;
this.spin = false; this.spin = false;
if(this.ticksExisted % Spells.lightning_hammer.getProperty(LightningHammer.ATTACK_INTERVAL).floatValue() == 0){ double seekerRange = Spells.lightning_hammer.getProperty(Spell.EFFECT_RADIUS).doubleValue();
double seekerRange = Spells.lightning_hammer.getProperty(Spell.EFFECT_RADIUS).doubleValue(); List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX,
this.posY + 1, this.posZ, world);
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, int maxTargets = Spells.lightning_hammer.getProperty(LightningHammer.SECONDARY_MAX_TARGETS).intValue();
this.posY + 1, this.posZ, world); while(targets.size() > maxTargets) targets.remove(targets.size() - 1);
int maxTargets = Spells.lightning_hammer.getProperty(LightningHammer.SECONDARY_MAX_TARGETS).intValue(); for(EntityLivingBase target : targets){
while(targets.size() > maxTargets) targets.remove(targets.size() - 1);
for(EntityLivingBase target : targets){ if(WizardryUtilities.isLiving(target) && this.isValidTarget(target)
&& target.ticksExisted % Spells.lightning_hammer.getProperty(LightningHammer.ATTACK_INTERVAL).floatValue() == 0){
if(WizardryUtilities.isLiving(target) && this.isValidTarget(target)){ if(world.isRemote){
if(world.isRemote){ ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world);
ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world); ParticleBuilder.spawnShockParticles(world, target.posX,
target.getEntityBoundingBox().minY + target.height, target.posZ);
}
ParticleBuilder.spawnShockParticles(world, target.posX, target.playSound(WizardrySounds.ENTITY_HAMMER_ATTACK, 1.0F, rand.nextFloat() * 0.4F + 1.5F);
target.getEntityBoundingBox().minY + target.height, target.posZ);
}
target.playSound(WizardrySounds.ENTITY_HAMMER_ATTACK, 1.0F, rand.nextFloat() * 0.4F + 1.5F); float damage = Spells.lightning_hammer.getProperty(Spell.SPLASH_DAMAGE).floatValue() * damageMultiplier;
float damage = Spells.lightning_hammer.getProperty(Spell.SPLASH_DAMAGE).floatValue() * damageMultiplier; if(this.getCaster() != null){
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage(
if(this.getCaster() != null){ this, getCaster(), DamageType.SHOCK), damage);
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage( WizardryUtilities.applyStandardKnockback(this, target);
this, getCaster(), DamageType.SHOCK), damage); }else{
WizardryUtilities.applyStandardKnockback(this, target); target.attackEntityFrom(DamageSource.MAGIC, damage);
}else{
target.attackEntityFrom(DamageSource.MAGIC, damage);
}
} }
} }
} }
@@ -62,7 +62,7 @@ public class EntityHealAura extends EntityMagicConstruct {
target.motionZ = velZ; target.motionZ = velZ;
} }
}else if(target.getHealth() < target.getMaxHealth() && this.ticksExisted % 5 == 0){ }else if(target.getHealth() < target.getMaxHealth() && target.ticksExisted % 5 == 0){
target.heal(Spells.healing_aura.getProperty(Spell.HEALTH).floatValue() * damageMultiplier); target.heal(Spells.healing_aura.getProperty(Spell.HEALTH).floatValue() * damageMultiplier);
} }
} }