This commit is contained in:
bm01 2012-02-27 03:39:06 +01:00
commit 8fe55812ef
3 changed files with 154 additions and 110 deletions

View File

@ -39,23 +39,30 @@ import com.gmail.nossr50.skills.Unarmed;
public class Combat public class Combat
{ {
public static void combatChecks(EntityDamageEvent event, mcMMO pluginx) public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx)
{ {
if(event.isCancelled() || event.getDamage() == 0 || event.getEntity().isDead()) if(event.isCancelled() || event.getDamage() == 0 || event.getEntity().isDead())
return; return;
if(event instanceof EntityDamageByEntityEvent)
{
//Declare Things //Declare Things
EntityDamageByEntityEvent eEvent = (EntityDamageByEntityEvent) event; Entity damager = event.getDamager();
Entity damager = eEvent.getDamager(); LivingEntity target = (LivingEntity) event.getEntity();
LivingEntity target = (LivingEntity) eEvent.getEntity(); int damage = event.getDamage();
int damage = eEvent.getDamage();
/* /*
* PLAYER VERSUS ENTITIES * PLAYER VERSUS ENTITIES
*/ */
if(damager instanceof Player) if(damager instanceof Player)
{
Player attacker = (Player) event.getDamager();
ItemStack itemInHand = attacker.getItemInHand();
PlayerProfile PPa = Users.getProfile(attacker);
//If there are any abilities to activate
combatAbilityChecks(attacker, PPa, pluginx);
//Damage modifiers and proc checks
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
{ {
Player attacker = (Player) eEvent.getDamager(); Player attacker = (Player) eEvent.getDamager();
ItemStack itemInHand = attacker.getItemInHand(); ItemStack itemInHand = attacker.getItemInHand();
@ -115,6 +122,32 @@ public class Combat
PvEExperienceGain(attacker, PPa, target, damage, SkillType.UNARMED); PvEExperienceGain(attacker, PPa, target, damage, SkillType.UNARMED);
} }
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
Axes.applyAoeDamage(attacker, event, pluginx);
if(target instanceof Player)
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES);
eEvent.setDamage(damage);
}
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
{
Unarmed.unarmedBonus(attacker, event);
if(PPa.getBerserkMode())
event.setDamage(event.getDamage() + (event.getDamage() / 2));
if(target instanceof Player)
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm
if(target instanceof Player)
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
}
//Player use bone on wolf. //Player use bone on wolf.
else if(target instanceof Wolf) else if(target instanceof Wolf)
{ {
@ -132,8 +165,6 @@ public class Combat
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()})); mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
} }
} }
eEvent.setDamage(damage);
} }
/* /*
@ -176,8 +207,8 @@ public class Combat
*/ */
if(target instanceof Player) if(target instanceof Player)
{ {
Swords.counterAttackChecks(eEvent); Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(eEvent); Acrobatics.dodgeChecks(event);
} }
/* /*
@ -187,8 +218,7 @@ public class Combat
{ {
Wolf wolf = (Wolf) target; Wolf wolf = (Wolf) target;
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx)) if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
Taming.preventDamage(eEvent, pluginx); Taming.preventDamage(event, pluginx);
}
} }
} }
@ -387,32 +417,48 @@ public class Combat
xp = (int) (xpinc * LoadProperties.animalXP); xp = (int) (xpinc * LoadProperties.animalXP);
else else
{ {
if(entity instanceof Enderman) EntityType type = entity.getType();
xp = (int) (xpinc * LoadProperties.endermanXP); switch(type){
else if(entity instanceof Creeper) case BLAZE:
xp = (int) (xpinc * LoadProperties.creeperXP);
else if(entity instanceof Silverfish)
xp = (int) (xpinc * LoadProperties.silverfishXP);
else if(entity instanceof CaveSpider)
xp = (int) (xpinc * LoadProperties.cavespiderXP);
else if(entity instanceof Spider)
xp = (int) (xpinc * LoadProperties.spiderXP);
else if(entity instanceof Skeleton)
xp = (int) (xpinc * LoadProperties.skeletonXP);
else if(entity instanceof Zombie)
xp = (int) (xpinc * LoadProperties.zombieXP);
else if(entity instanceof PigZombie)
xp = (int) (xpinc * LoadProperties.pigzombieXP);
else if(entity instanceof Slime)
xp = (int) (xpinc * LoadProperties.slimeXP);
else if(entity instanceof Ghast)
xp = (int) (xpinc * LoadProperties.ghastXP);
else if(entity instanceof Blaze)
xp = (int) (xpinc * LoadProperties.blazeXP); xp = (int) (xpinc * LoadProperties.blazeXP);
else if(entity instanceof EnderDragon) break;
case CAVE_SPIDER:
xp = (int) (xpinc * LoadProperties.cavespiderXP);
break;
case CREEPER:
xp = (int) (xpinc * LoadProperties.creeperXP);
break;
case ENDER_DRAGON:
xp = (int) (xpinc * LoadProperties.enderdragonXP); xp = (int) (xpinc * LoadProperties.enderdragonXP);
else if(entity instanceof MagmaCube) break;
case ENDERMAN:
xp = (int) (xpinc * LoadProperties.endermanXP);
break;
case GHAST:
xp = (int) (xpinc * LoadProperties.ghastXP);
break;
case MAGMA_CUBE:
xp = (int) (xpinc * LoadProperties.magmacubeXP); xp = (int) (xpinc * LoadProperties.magmacubeXP);
break;
case PIG_ZOMBIE:
xp = (int) (xpinc * LoadProperties.pigzombieXP);
break;
case SILVERFISH:
xp = (int) (xpinc * LoadProperties.silverfishXP);
break;
case SKELETON:
xp = (int) (xpinc * LoadProperties.skeletonXP);
break;
case SLIME:
xp = (int) (xpinc * LoadProperties.slimeXP);
break;
case SPIDER:
xp = (int) (xpinc * LoadProperties.spiderXP);
break;
case ZOMBIE:
xp = (int) (xpinc * LoadProperties.zombieXP);
break;
}
} }
} }
return xp; return xp;

View File

@ -125,7 +125,7 @@ public class mcEntityListener implements Listener
if(Party.getInstance().inSameParty(defender, attacker)) if(Party.getInstance().inSameParty(defender, attacker))
event.setCancelled(true); event.setCancelled(true);
} }
Combat.combatChecks(event, plugin); Combat.combatChecks(eventb, plugin);
} }
/* /*
* Check to see if the defender took damage so we can apply recently hurt * Check to see if the defender took damage so we can apply recently hurt

View File

@ -16,7 +16,6 @@
*/ */
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
@ -49,7 +48,6 @@ public class Unarmed
y.sendMessage(mcLocale.getString("Skills.BerserkPlayer", new Object[] {player.getName()})); y.sendMessage(mcLocale.getString("Skills.BerserkPlayer", new Object[] {player.getName()}));
} }
PPa.setSkillDATS(AbilityType.BERSERK, System.currentTimeMillis()+(ticks*1000)); PPa.setSkillDATS(AbilityType.BERSERK, System.currentTimeMillis()+(ticks*1000));
//System.out.println("getSkillDATS(): "+PPa.getSkillDATS(AbilityType.BERSERK));
PPa.setBerserkMode(true); PPa.setBerserkMode(true);
} }
} }