mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-05 07:01:21 +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
|
name: MobArena
|
||||||
author: garbagemule
|
author: garbagemule
|
||||||
main: com.garbagemule.MobArena.MobArena
|
main: com.garbagemule.MobArena.MobArena
|
||||||
version: 0.94.4.91
|
version: 0.94.4.92
|
||||||
softdepend: [Spout,MultiVerse,MultiWorld,XcraftGate,Towny,Heroes,MagicSpells,Vault]
|
softdepend: [Spout,MultiVerse,MultiWorld,XcraftGate,Towny,Heroes,MagicSpells,Vault]
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
|
@ -499,7 +499,7 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
// Boss
|
// Boss
|
||||||
else if (monsters.getBossMonsters().contains(damagee)) {
|
else if (monsters.getBossMonsters().contains(damagee)) {
|
||||||
onBossDamage(event, (LivingEntity) damagee, damager);
|
onBossDamage(event, (LivingEntity) damagee, damager); // Now an emtpy method
|
||||||
}
|
}
|
||||||
// Regular monster
|
// Regular monster
|
||||||
else if (monsters.getMonsters().contains(damagee)) {
|
else if (monsters.getMonsters().contains(damagee)) {
|
||||||
@ -519,7 +519,7 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
// If PvP is disabled and damager is a player, cancel damage
|
// If PvP is disabled and damager is a player, cancel damage
|
||||||
else if (arena.inArena(player)) {
|
else if (arena.inArena(player)) {
|
||||||
if (!pvpEnabled && damager instanceof Player) {
|
if (!pvpEnabled && (damager instanceof Player || damager instanceof Wolf)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -549,8 +549,8 @@ public class ArenaListener
|
|||||||
Player p = (Player) ((Wolf) damager).getOwner();
|
Player p = (Player) ((Wolf) damager).getOwner();
|
||||||
ArenaPlayerStatistics aps = arena.getArenaPlayer(p).getStats();
|
ArenaPlayerStatistics aps = arena.getArenaPlayer(p).getStats();
|
||||||
aps.add("dmgDone", event.getDamage());
|
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) {
|
else if (damager instanceof LivingEntity) {
|
||||||
if (!monsterInfight)
|
if (!monsterInfight)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -573,21 +573,7 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onBossDamage(EntityDamageEvent event, LivingEntity monster, Entity damager) {
|
private void onBossDamage(EntityDamageEvent event, LivingEntity monster, Entity damager) {
|
||||||
// Health the boss back up.
|
//TODO useless method as of Entity Max Health API, maybe add in some stat tracking for leaderboards instead?
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityCombust(EntityCombustEvent event) {
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
|
@ -156,8 +156,10 @@ public class MASpawnThread implements Runnable
|
|||||||
monsterManager.addMonster(e);
|
monsterManager.addMonster(e);
|
||||||
|
|
||||||
// Set the health.
|
// Set the health.
|
||||||
|
e.resetMaxHealth(); // Avoid conflicts/enormous multiplications from other plugins handling Mob health
|
||||||
int health = (int) Math.max(1D, e.getMaxHealth() * mul);
|
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 on the type.
|
||||||
switch (w.getType()){
|
switch (w.getType()){
|
||||||
|
@ -71,9 +71,8 @@ public class Leaderboard
|
|||||||
*/
|
*/
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
if (!isGridWellFormed()) {
|
if (!isGridWellFormed())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
initializeBoards();
|
initializeBoards();
|
||||||
initializeStats();
|
initializeStats();
|
||||||
@ -117,9 +116,8 @@ public class Leaderboard
|
|||||||
*/
|
*/
|
||||||
private boolean isGridWellFormed()
|
private boolean isGridWellFormed()
|
||||||
{
|
{
|
||||||
if (topLeft == null) {
|
if (topLeft == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
BlockState state = topLeft.getBlock().getState();
|
BlockState state = topLeft.getBlock().getState();
|
||||||
|
|
||||||
@ -139,9 +137,8 @@ public class Leaderboard
|
|||||||
this.cols = getSignCount(current, direction);
|
this.cols = getSignCount(current, direction);
|
||||||
|
|
||||||
// Require at least 2x2 to be valid
|
// Require at least 2x2 to be valid
|
||||||
if (rows <= 1 || cols <= 1) {
|
if (rows <= 1 || cols <= 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// Get the left-most sign in the current row.
|
// Get the left-most sign in the current row.
|
||||||
Sign first = getAdjacentSign(current, BlockFace.DOWN);
|
Sign first = getAdjacentSign(current, BlockFace.DOWN);
|
||||||
@ -242,10 +239,10 @@ public class Leaderboard
|
|||||||
{
|
{
|
||||||
byte data = s.getRawData();
|
byte data = s.getRawData();
|
||||||
|
|
||||||
if (data == 2) return BlockFace.WEST;//BlockFace.NORTH;
|
if (data == 2) return BlockFace.NORTH;
|
||||||
if (data == 3) return BlockFace.EAST;//BlockFace.SOUTH;
|
if (data == 3) return BlockFace.SOUTH;
|
||||||
if (data == 4) return BlockFace.SOUTH;//BlockFace.WEST;
|
if (data == 4) return BlockFace.WEST;
|
||||||
if (data == 5) return BlockFace.NORTH;//BlockFace.EAST;
|
if (data == 5) return BlockFace.EAST;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
public class MABoss
|
public class MABoss
|
||||||
{
|
{
|
||||||
private LivingEntity entity;
|
private LivingEntity entity;
|
||||||
private int health, health25, maxHealth;
|
private boolean dead;
|
||||||
private boolean dead, lowHealth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an MABoss from the given entity with the given max health.
|
* 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
|
* @param maxHealth a max health value
|
||||||
*/
|
*/
|
||||||
public MABoss(LivingEntity entity, int maxHealth) {
|
public MABoss(LivingEntity entity, int maxHealth) {
|
||||||
|
entity.setMaxHealth(maxHealth);
|
||||||
|
entity.setHealth(maxHealth);
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.dead = false;
|
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
|
* @return the current health of the boss
|
||||||
*/
|
*/
|
||||||
public int getHealth() {
|
public int getHealth() {
|
||||||
return health;
|
return entity.getHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,47 +40,7 @@ public class MABoss
|
|||||||
* @return the maximum health of the boss
|
* @return the maximum health of the boss
|
||||||
*/
|
*/
|
||||||
public int getMaxHealth() {
|
public int getMaxHealth() {
|
||||||
return maxHealth;
|
return entity.getMaxHealth();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user