@Override public void onDamage( int amount, World world, Player player, BlockCoord coord, BuildableDamageBlock hit) { ControlPoint cp = this.controlPoints.get(coord); Resident resident = CivGlobal.getResident(player); if (!resident.canDamageControlBlock()) { CivMessage.send( player, CivColor.Rose + "Cannot damage control blocks due to missing/invalid Town Hall or Capitol structure."); return; } if (cp != null) { if (!cp.isDestroyed()) { if (resident.isControlBlockInstantBreak()) { cp.damage(cp.getHitpoints()); } else { cp.damage(amount); } if (cp.isDestroyed()) { onControlBlockDestroy(cp, world, player, (StructureBlock) hit); } else { onControlBlockHit(cp, world, player, (StructureBlock) hit); } } else { CivMessage.send(player, CivColor.Rose + "Control Block already destroyed."); } } else { CivMessage.send( player, CivColor.Rose + "Cannot Damage " + this.getDisplayName() + ", go after the control points!"); } }
public void onCannonDamage(int damage, CannonProjectile projectile) throws CivException { this.hitpoints -= damage; Resident resident = projectile.whoFired; if (hitpoints <= 0) { for (BlockCoord coord : this.controlPoints.keySet()) { ControlPoint cp = this.controlPoints.get(coord); if (cp != null) { if (cp.getHitpoints() > CannonProjectile.controlBlockHP) { cp.damage(cp.getHitpoints() - 1); this.hitpoints = this.getMaxHitPoints() / 2; StructureBlock hit = CivGlobal.getStructureBlock(coord); onControlBlockCannonDestroy(cp, CivGlobal.getPlayer(resident), hit); CivMessage.sendCiv( getCiv(), "Our " + this.getDisplayName() + " has been hit by a cannon and a control block was set to " + CannonProjectile.controlBlockHP + " HP!"); CivMessage.sendCiv( getCiv(), "Our " + this.getDisplayName() + " has regenerated " + this.getMaxHitPoints() / 2 + " HP! If it drops to zero, we will lose another Control Point."); return; } } } CivMessage.sendCiv( getCiv(), "Our " + this.getDisplayName() + " is out of hitpoints, walls can be destroyed by cannon and TNT blasts!"); hitpoints = 0; } CivMessage.sendCiv( getCiv(), "Our " + this.getDisplayName() + " has been hit by a cannon! (" + this.hitpoints + "/" + this.getMaxHitPoints() + ")"); }