mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-01-27 10:41:19 +01:00
update boss health using new Entity Max Health API/fix health-multiplier values > 1 on default style waves
This commit is contained in:
parent
60e5324ea6
commit
1f03436f40
@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
author: garbagemule
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.94.4.91
|
||||
version: 0.94.4.92
|
||||
softdepend: [Spout,MultiVerse,MultiWorld,XcraftGate,Towny,Heroes,MagicSpells,Vault]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -499,7 +499,7 @@ public class ArenaListener
|
||||
}
|
||||
// Boss
|
||||
else if (monsters.getBossMonsters().contains(damagee)) {
|
||||
onBossDamage(event, (LivingEntity) damagee, damager);
|
||||
onBossDamage(event, (LivingEntity) damagee, damager); // Now an emtpy method
|
||||
}
|
||||
// Regular monster
|
||||
else if (monsters.getMonsters().contains(damagee)) {
|
||||
@ -519,7 +519,7 @@ public class ArenaListener
|
||||
}
|
||||
// If PvP is disabled and damager is a player, cancel damage
|
||||
else if (arena.inArena(player)) {
|
||||
if (!pvpEnabled && damager instanceof Player) {
|
||||
if (!pvpEnabled && (damager instanceof Player || damager instanceof Wolf)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -549,8 +549,8 @@ public class ArenaListener
|
||||
Player p = (Player) ((Wolf) damager).getOwner();
|
||||
ArenaPlayerStatistics aps = arena.getArenaPlayer(p).getStats();
|
||||
aps.add("dmgDone", event.getDamage());
|
||||
// arena.getArenaPlayer(p).getStats().dmgDone += event.getDamage();
|
||||
}
|
||||
//TODO add in check for player made golems doing damage
|
||||
else if (damager instanceof LivingEntity) {
|
||||
if (!monsterInfight)
|
||||
event.setCancelled(true);
|
||||
@ -573,21 +573,7 @@ public class ArenaListener
|
||||
}
|
||||
|
||||
private void onBossDamage(EntityDamageEvent event, LivingEntity monster, Entity damager) {
|
||||
// Health the boss back up.
|
||||
monster.setHealth(monster.getMaxHealth());
|
||||
|
||||
// Damage the underlying MABoss.
|
||||
MABoss boss = monsters.getBoss(monster);
|
||||
boss.damage(event.getDamage());
|
||||
|
||||
// If it died, remove it from the arena.
|
||||
if (boss.isDead()) {
|
||||
monsters.removeBoss(monster);
|
||||
monster.damage(10000);
|
||||
}
|
||||
|
||||
// And "cancel out" the damage.
|
||||
event.setDamage(1);
|
||||
//TODO useless method as of Entity Max Health API, maybe add in some stat tracking for leaderboards instead?
|
||||
}
|
||||
|
||||
public void onEntityCombust(EntityCombustEvent event) {
|
||||
|
@ -156,8 +156,10 @@ public class MASpawnThread implements Runnable
|
||||
monsterManager.addMonster(e);
|
||||
|
||||
// Set the health.
|
||||
e.resetMaxHealth(); // Avoid conflicts/enormous multiplications from other plugins handling Mob health
|
||||
int health = (int) Math.max(1D, e.getMaxHealth() * mul);
|
||||
e.setHealth(Math.min(health, e.getMaxHealth()));
|
||||
e.setMaxHealth(health);
|
||||
e.setHealth(health);
|
||||
|
||||
// Switch on the type.
|
||||
switch (w.getType()){
|
||||
|
@ -71,9 +71,8 @@ public class Leaderboard
|
||||
*/
|
||||
public void initialize()
|
||||
{
|
||||
if (!isGridWellFormed()) {
|
||||
if (!isGridWellFormed())
|
||||
return;
|
||||
}
|
||||
|
||||
initializeBoards();
|
||||
initializeStats();
|
||||
@ -117,9 +116,8 @@ public class Leaderboard
|
||||
*/
|
||||
private boolean isGridWellFormed()
|
||||
{
|
||||
if (topLeft == null) {
|
||||
if (topLeft == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState state = topLeft.getBlock().getState();
|
||||
|
||||
@ -139,9 +137,8 @@ public class Leaderboard
|
||||
this.cols = getSignCount(current, direction);
|
||||
|
||||
// Require at least 2x2 to be valid
|
||||
if (rows <= 1 || cols <= 1) {
|
||||
if (rows <= 1 || cols <= 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the left-most sign in the current row.
|
||||
Sign first = getAdjacentSign(current, BlockFace.DOWN);
|
||||
@ -242,10 +239,10 @@ public class Leaderboard
|
||||
{
|
||||
byte data = s.getRawData();
|
||||
|
||||
if (data == 2) return BlockFace.WEST;//BlockFace.NORTH;
|
||||
if (data == 3) return BlockFace.EAST;//BlockFace.SOUTH;
|
||||
if (data == 4) return BlockFace.SOUTH;//BlockFace.WEST;
|
||||
if (data == 5) return BlockFace.NORTH;//BlockFace.EAST;
|
||||
if (data == 2) return BlockFace.NORTH;
|
||||
if (data == 3) return BlockFace.SOUTH;
|
||||
if (data == 4) return BlockFace.WEST;
|
||||
if (data == 5) return BlockFace.EAST;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
public class MABoss
|
||||
{
|
||||
private LivingEntity entity;
|
||||
private int health, health25, maxHealth;
|
||||
private boolean dead, lowHealth;
|
||||
private boolean dead;
|
||||
|
||||
/**
|
||||
* Create an MABoss from the given entity with the given max health.
|
||||
@ -14,12 +13,10 @@ public class MABoss
|
||||
* @param maxHealth a max health value
|
||||
*/
|
||||
public MABoss(LivingEntity entity, int maxHealth) {
|
||||
entity.setMaxHealth(maxHealth);
|
||||
entity.setHealth(maxHealth);
|
||||
this.entity = entity;
|
||||
this.dead = false;
|
||||
this.lowHealth = false;
|
||||
|
||||
this.health = this.maxHealth = maxHealth;
|
||||
this.health25 = maxHealth / 4;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,7 +32,7 @@ public class MABoss
|
||||
* @return the current health of the boss
|
||||
*/
|
||||
public int getHealth() {
|
||||
return health;
|
||||
return entity.getHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,47 +40,7 @@ public class MABoss
|
||||
* @return the maximum health of the boss
|
||||
*/
|
||||
public int getMaxHealth() {
|
||||
return maxHealth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the health of this boss as a percentage between 1 and 100.
|
||||
* @param percentage an integer percentage
|
||||
*/
|
||||
public void setHealth(int percentage) {
|
||||
if (percentage < 1) {
|
||||
percentage = 1;
|
||||
}
|
||||
else if (percentage > 100) {
|
||||
percentage = 100;
|
||||
}
|
||||
|
||||
health = maxHealth * percentage / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Heal the boss for the given amount. Useful for "siphon life"-like abilities.
|
||||
* @param amount the health amount
|
||||
*/
|
||||
public void heal(int amount) {
|
||||
health = Math.min(maxHealth, health + amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Damage the boss for the given amount. Used internally by MobArena.
|
||||
* @param amount the amount.
|
||||
*/
|
||||
public void damage(int amount) {
|
||||
health -= amount;
|
||||
|
||||
if (health <= health25 && !lowHealth) {
|
||||
lowHealth = true;
|
||||
//System.out.println("Boss is at 25%!");
|
||||
}
|
||||
|
||||
if (health <= 0) {
|
||||
dead = true;
|
||||
}
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user