2012-01-09 20:00:13 +01:00
/ *
This file is part of mcMMO .
mcMMO is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
mcMMO is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with mcMMO . If not , see < http : //www.gnu.org/licenses/>.
* /
package com.gmail.nossr50.skills ;
2012-02-29 20:56:15 +01:00
import org.bukkit.Material ;
2012-01-09 20:00:13 +01:00
import org.bukkit.entity.Entity ;
import org.bukkit.entity.LivingEntity ;
import org.bukkit.entity.Player ;
import org.bukkit.entity.Wolf ;
import org.bukkit.event.entity.EntityDamageByEntityEvent ;
2012-02-29 20:56:15 +01:00
import org.bukkit.inventory.ItemStack ;
2012-01-09 20:00:13 +01:00
import org.bukkit.plugin.Plugin ;
2012-01-28 07:24:29 +01:00
import com.gmail.nossr50.Combat ;
2012-01-09 20:00:13 +01:00
import com.gmail.nossr50.Users ;
import com.gmail.nossr50.m ;
import com.gmail.nossr50.mcPermissions ;
import com.gmail.nossr50.datatypes.PlayerProfile ;
import com.gmail.nossr50.datatypes.SkillType ;
2012-03-01 01:04:31 +01:00
import com.gmail.nossr50.locale.mcLocale ;
2012-01-09 20:00:13 +01:00
import com.gmail.nossr50.party.Party ;
public class Axes {
2012-03-01 00:40:16 +01:00
public static void axesBonus ( Player attacker , EntityDamageByEntityEvent event )
{
int bonus = 0 ;
//Add 1 DMG for every 50 skill levels
bonus + = Users . getProfile ( attacker ) . getSkillLevel ( SkillType . AXES ) / 50 ;
if ( bonus > 4 )
bonus = 4 ;
event . setDamage ( event . getDamage ( ) + bonus ) ;
}
2012-01-09 20:00:13 +01:00
public static void axeCriticalCheck ( Player attacker , EntityDamageByEntityEvent event , Plugin pluginx )
{
Entity x = event . getEntity ( ) ;
2012-02-09 06:58:05 +01:00
2012-01-09 20:00:13 +01:00
if ( x instanceof Wolf ) {
Wolf wolf = ( Wolf ) x ;
2012-03-02 19:55:23 +01:00
if ( wolf . getOwner ( ) instanceof Player )
2012-01-09 20:00:13 +01:00
{
2012-03-02 19:55:23 +01:00
Player owner = ( Player ) wolf . getOwner ( ) ;
if ( owner = = attacker )
2012-01-09 20:00:13 +01:00
return ;
2012-03-02 19:55:23 +01:00
if ( Party . getInstance ( ) . inSameParty ( attacker , owner ) )
2012-01-09 20:00:13 +01:00
return ;
}
}
PlayerProfile PPa = Users . getProfile ( attacker ) ;
if ( m . isAxes ( attacker . getItemInHand ( ) ) & & mcPermissions . getInstance ( ) . axes ( attacker ) ) {
if ( PPa . getSkillLevel ( SkillType . AXES ) > = 750 ) {
2012-03-03 01:46:38 +01:00
if ( Math . random ( ) * 2000 < = 750 & & ! x . isDead ( ) ) {
2012-01-09 20:00:13 +01:00
if ( x instanceof Player ) {
2012-02-09 06:58:05 +01:00
int damage = ( event . getDamage ( ) * 2 ) - ( event . getDamage ( ) / 2 ) ;
event . setDamage ( damage ) ;
2012-01-09 20:00:13 +01:00
Player player = ( Player ) x ;
2012-03-03 20:48:40 +01:00
player . sendMessage ( mcLocale . getString ( " Axes.HitCritically " ) ) ;
2012-01-09 20:00:13 +01:00
}
2012-02-09 06:58:05 +01:00
else {
int damage = event . getDamage ( ) * 2 ;
event . setDamage ( damage ) ;
2012-01-09 20:00:13 +01:00
}
2012-03-03 20:48:40 +01:00
attacker . sendMessage ( mcLocale . getString ( " Axes.CriticalHit " ) ) ;
2012-01-09 20:00:13 +01:00
}
2012-03-03 01:46:38 +01:00
} else if ( Math . random ( ) * 2000 < = PPa . getSkillLevel ( SkillType . AXES ) & & ! x . isDead ( ) ) {
2012-01-09 20:00:13 +01:00
if ( x instanceof Player ) {
2012-02-09 06:58:05 +01:00
int damage = ( event . getDamage ( ) * 2 ) - ( event . getDamage ( ) / 2 ) ;
event . setDamage ( damage ) ;
2012-01-09 20:00:13 +01:00
Player player = ( Player ) x ;
2012-03-03 20:48:40 +01:00
player . sendMessage ( mcLocale . getString ( " Axes.HitCritically " ) ) ;
2012-01-09 20:00:13 +01:00
}
2012-02-09 06:58:05 +01:00
else {
int damage = event . getDamage ( ) * 2 ;
event . setDamage ( damage ) ;
2012-01-09 20:00:13 +01:00
}
2012-03-03 20:48:40 +01:00
attacker . sendMessage ( mcLocale . getString ( " Axes.CriticalHit " ) ) ;
2012-01-09 20:00:13 +01:00
}
}
}
2012-03-03 01:46:38 +01:00
public static void impact ( Player attacker , LivingEntity target , EntityDamageByEntityEvent event )
2012-02-29 20:56:15 +01:00
{
2012-02-29 22:19:22 +01:00
//TODO: Finish this skill, the idea is you will greatly damage an opponents armor and when they are armor less you have a proc that will stun them and deal additional damage.
2012-02-29 20:56:15 +01:00
if ( target instanceof Player )
{
Player targetPlayer = ( Player ) target ;
int emptySlots = 0 ;
2012-03-01 00:40:16 +01:00
short durDmg = 5 ; //Start with 5 durability dmg
durDmg + = Users . getProfile ( attacker ) . getSkillLevel ( SkillType . AXES ) / 30 ; //Every 30 Skill Levels you gain 1 durability dmg
2012-02-29 20:56:15 +01:00
for ( ItemStack x : targetPlayer . getInventory ( ) . getArmorContents ( ) )
{
if ( x . getType ( ) = = Material . AIR )
{
emptySlots + + ;
} else {
2012-03-01 00:40:16 +01:00
x . setDurability ( ( short ) ( x . getDurability ( ) + durDmg ) ) ; //Damage armor piece
2012-02-29 20:56:15 +01:00
}
}
if ( emptySlots = = 4 )
2012-03-03 01:46:38 +01:00
applyImpact ( attacker , target , event ) ;
2012-02-29 20:56:15 +01:00
}
2012-03-02 23:19:12 +01:00
else
//Since mobs are technically unarmored this will always trigger
2012-03-03 01:46:38 +01:00
applyImpact ( attacker , target , event ) ;
2012-02-29 20:56:15 +01:00
}
2012-03-03 01:46:38 +01:00
public static void applyImpact ( Player attacker , LivingEntity target , EntityDamageByEntityEvent event )
2012-02-29 20:56:15 +01:00
{
if ( Math . random ( ) * 100 > 75 )
{
2012-03-03 01:46:38 +01:00
event . setDamage ( event . getDamage ( ) + 2 ) ;
2012-03-01 00:22:03 +01:00
target . setVelocity ( attacker . getLocation ( ) . getDirection ( ) . normalize ( ) . multiply ( 1 . 5D ) ) ;
2012-03-02 23:19:12 +01:00
attacker . sendMessage ( mcLocale . getString ( " Axes.GreaterImpactOnEnemy " ) ) ;
2012-02-29 20:56:15 +01:00
}
}
2012-01-09 20:00:13 +01:00
public static void applyAoeDamage ( Player attacker , EntityDamageByEntityEvent event , Plugin pluginx )
{
int targets = 0 ;
2012-02-14 19:33:49 +01:00
int dmgAmount = ( event . getDamage ( ) / 2 ) ;
//Setup minimum damage
if ( dmgAmount < 1 )
dmgAmount = 1 ;
2012-01-09 20:00:13 +01:00
if ( event . getEntity ( ) instanceof LivingEntity )
{
LivingEntity x = ( LivingEntity ) event . getEntity ( ) ;
targets = m . getTier ( attacker ) ;
2012-02-09 06:58:05 +01:00
for ( Entity derp : x . getNearbyEntities ( 2 . 5 , 2 . 5 , 2 . 5 ) )
{
//Make sure the Wolf is not friendly
if ( derp instanceof Wolf )
{
Wolf hurrDurr = ( Wolf ) derp ;
2012-03-02 19:55:23 +01:00
if ( hurrDurr . getOwner ( ) instanceof Player )
{
Player owner = ( Player ) hurrDurr . getOwner ( ) ;
if ( owner = = attacker )
return ;
if ( Party . getInstance ( ) . inSameParty ( attacker , owner ) )
return ;
}
2012-02-09 06:58:05 +01:00
}
2012-02-14 19:33:49 +01:00
2012-02-09 06:58:05 +01:00
//Damage nearby LivingEntities
if ( derp instanceof LivingEntity & & targets > = 1 )
{
if ( derp instanceof Player )
2012-01-09 20:00:13 +01:00
{
2012-02-09 06:58:05 +01:00
Player target = ( Player ) derp ;
if ( Users . getProfile ( target ) . getGodMode ( ) )
continue ;
2012-01-09 20:00:13 +01:00
2012-02-09 06:58:05 +01:00
if ( target . getName ( ) . equals ( attacker . getName ( ) ) )
continue ;
if ( Party . getInstance ( ) . inSameParty ( attacker , target ) )
continue ;
if ( target . isDead ( ) )
continue ;
2012-02-14 19:33:49 +01:00
if ( targets > = 1 & & derp . getWorld ( ) . getPVP ( ) )
2012-02-09 06:58:05 +01:00
{
2012-02-15 22:57:48 +01:00
Combat . dealDamage ( target , dmgAmount , attacker ) ;
2012-03-03 20:48:40 +01:00
target . sendMessage ( mcLocale . getString ( " Axes.HitByCleave " ) ) ;
2012-02-09 06:58:05 +01:00
targets - - ;
continue ;
}
2012-02-14 19:33:49 +01:00
}
2012-02-09 06:58:05 +01:00
else
{
LivingEntity target = ( LivingEntity ) derp ;
2012-02-15 22:57:48 +01:00
Combat . dealDamage ( target , dmgAmount , attacker ) ;
2012-02-09 06:58:05 +01:00
targets - - ;
2012-01-09 20:00:13 +01:00
}
2012-02-09 06:58:05 +01:00
}
}
2012-01-09 20:00:13 +01:00
}
2012-02-09 06:58:05 +01:00
}
2012-01-09 20:00:13 +01:00
}