Archery optimizations.

This commit is contained in:
GJ 2012-02-23 21:13:06 -05:00
parent cd56dc7f98
commit 1fe259eb7a
3 changed files with 37 additions and 57 deletions

View File

@ -24,7 +24,7 @@ Version 1.3.00-dev
= Fixed memory leak with mob spawner tracking = Fixed memory leak with mob spawner tracking
= Fixed /mcability not respecting permissions = Fixed /mcability not respecting permissions
= Prettied up new config files = Prettied up new config files
= Optimized repair functions = Various skill function optimizations
! Changed mcMMO user information to be stored for 2 minutes after log out to reduce lag on rejoins ! Changed mcMMO user information to be stored for 2 minutes after log out to reduce lag on rejoins
! Changed the name of Unarmed Apprentice/Mastery to Iron Arm Style ! Changed the name of Unarmed Apprentice/Mastery to Iron Arm Style
! Changed Unarmed to start with a +3 DMG bonus from Iron Arm Style to make leveling it more viable ! Changed Unarmed to start with a +3 DMG bonus from Iron Arm Style to make leveling it more viable

View File

@ -17,7 +17,6 @@
package com.gmail.nossr50; package com.gmail.nossr50;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -254,6 +253,7 @@ public class Combat
if(PPa.getFistsPreparationMode()) if(PPa.getFistsPreparationMode())
Unarmed.berserkActivationCheck(attacker); Unarmed.berserkActivationCheck(attacker);
} }
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
{ {
Arrow arrow = (Arrow)event.getDamager(); Arrow arrow = (Arrow)event.getDamager();
@ -290,20 +290,21 @@ public class Combat
{ {
Player attacker = (Player)y; Player attacker = (Player)y;
PlayerProfile PPa = Users.getProfile(attacker); PlayerProfile PPa = Users.getProfile(attacker);
if(mcPermissions.getInstance().archery(attacker)) int damage = event.getDamage();
if(mcPermissions.getInstance().archery(attacker) && damage > 0)
{ {
Archery.trackArrows(pluginx, x, event, attacker); Archery.trackArrows(pluginx, x, PPa);
/* /*
* IGNITION * IGNITION
*/ */
Archery.ignitionCheck(x, event, attacker); Archery.ignitionCheck(x, attacker);
/* /*
* Defender is Monster * Defender is Monster
*/ */
if(!pluginx.misc.mobSpawnerList.contains(x.getEntityId())) if(!pluginx.misc.mobSpawnerList.contains(x.getEntityId()))
{ {
int xp = getXp(event.getEntity(), event); int xp = getXp(x, event);
PPa.addXP(SkillType.ARCHERY, xp*10, attacker); PPa.addXP(SkillType.ARCHERY, xp*10, attacker);
} }
/* /*
@ -326,10 +327,9 @@ public class Combat
/* /*
* PVP XP * PVP XP
*/ */
if(LoadProperties.pvpxp && !Party.getInstance().inSameParty(attacker, defender) if(LoadProperties.pvpxp && ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis() && !attacker.getName().equals(defender.getName()))
&& ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis() && !attacker.getName().equals(defender.getName()))
{ {
int xp = (int) ((event.getDamage() * 2) * 10); int xp = (int) ((damage * 2) * 10);
PPa.addXP(SkillType.ARCHERY, xp, attacker); PPa.addXP(SkillType.ARCHERY, xp, attacker);
} }
/* /*
@ -390,13 +390,6 @@ public class Combat
} }
} }
public static boolean pvpAllowed(EntityDamageByEntityEvent event, World world)
{
if(!event.getEntity().getWorld().getPVP())
return false;
//If it made it this far, pvp is enabled
return true;
}
public static int getXp(Entity entity, EntityDamageEvent event) public static int getXp(Entity entity, EntityDamageEvent event)
{ {
int xp = 0; int xp = 0;

View File

@ -19,7 +19,6 @@ package com.gmail.nossr50.skills;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
@ -29,34 +28,16 @@ import com.gmail.nossr50.party.Party;
public class Archery public class Archery
{ {
public static void trackArrows(mcMMO pluginx, Entity x, EntityDamageByEntityEvent event, Player attacker) public static void trackArrows(mcMMO pluginx, Entity x, PlayerProfile PPa)
{ {
PlayerProfile PPa = Users.getProfile(attacker); int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
if(!pluginx.misc.arrowTracker.containsKey(x) && event.getDamage() > 0) if(!pluginx.misc.arrowTracker.containsKey(x))
{
pluginx.misc.arrowTracker.put(x, 0); pluginx.misc.arrowTracker.put(x, 0);
if(attacker != null) if(skillLevel > 1000 || (Math.random() * 1000 <= skillLevel))
{ pluginx.misc.arrowTracker.put(x, 1);
if(PPa.getSkillLevel(SkillType.ARCHERY) > 1000 || (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY)))
{
pluginx.misc.arrowTracker.put(x, 1);
}
}
} else
{
if(event.getDamage() > 0)
{
if(attacker != null)
{
if(PPa.getSkillLevel(SkillType.ARCHERY) > 1000 || (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY)))
{
pluginx.misc.arrowTracker.put(x, 1);
}
}
}
}
} }
public static void ignitionCheck(Entity x, EntityDamageByEntityEvent event, Player attacker)
public static void ignitionCheck(Entity x, Player attacker)
{ {
//Check to see if PVP for this world is disabled before executing //Check to see if PVP for this world is disabled before executing
if(!x.getWorld().getPVP()) if(!x.getWorld().getPVP())
@ -73,37 +54,43 @@ public class Archery
if(x instanceof Player) if(x instanceof Player)
{ {
Player Defender = (Player)x; Player defender = (Player)x;
if(!Party.getInstance().inSameParty(attacker, Defender)) if(!Party.getInstance().inSameParty(attacker, defender))
{ {
event.getEntity().setFireTicks(ignition); defender.setFireTicks(ignition);
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$ attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
Defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit")); //$NON-NLS-1$ defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit")); //$NON-NLS-1$
} }
} else { }
event.getEntity().setFireTicks(ignition); else
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$ {
x.setFireTicks(ignition);
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
} }
} }
} }
public static void dazeCheck(Player defender, Player attacker) public static void dazeCheck(Player defender, Player attacker)
{ {
PlayerProfile PPa = Users.getProfile(attacker); int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
Location loc = defender.getLocation(); Location loc = defender.getLocation();
if(Math.random() * 10 > 5) if(Math.random() * 10 > 5)
{ loc.setPitch(90);
loc.setPitch(90); else
} else {
loc.setPitch(-90); loc.setPitch(-90);
}
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000){ if(skillLevel >= 1000)
if(Math.random() * 1000 <= 500){ {
if(Math.random() * 1000 <= 500)
{
defender.teleport(loc); defender.teleport(loc);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$ defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$ attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
} }
} else if(Math.random() * 2000 <= PPa.getSkillLevel(SkillType.ARCHERY)){ }
else if(Math.random() * 2000 <= skillLevel)
{
defender.teleport(loc); defender.teleport(loc);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$ defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$ attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$