Fixed damage rate limiting for mobs.

This commit is contained in:
Jonathan Williams 2014-03-22 00:16:51 -07:00
parent 8bf78fe14d
commit 2450265909
3 changed files with 12 additions and 9 deletions

View File

@ -108,7 +108,7 @@
<zipfileset src="../Libraries/httpmime-4.2.jar" /> <zipfileset src="../Libraries/httpmime-4.2.jar" />
<zipfileset src="../Libraries/gson-2.2.1.jar" /> <zipfileset src="../Libraries/gson-2.2.1.jar" />
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" /> <zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
<zipfileset src="../Libraries/commons-io-2.4" /> <zipfileset src="../Libraries/commons-io-2.4.jar" />
<zipfileset src="../Libraries/commons-codec-1.6.jar" /> <zipfileset src="../Libraries/commons-codec-1.6.jar" />
</jar> </jar>
<copy file="../bin/Hub.jar" todir="../../Testing/Hub/plugins"/> <copy file="../bin/Hub.jar" todir="../../Testing/Hub/plugins"/>

View File

@ -12,7 +12,7 @@ public class ClientCombat
private LinkedList<CombatLog> _deaths = new LinkedList<CombatLog>(); private LinkedList<CombatLog> _deaths = new LinkedList<CombatLog>();
private WeakHashMap<LivingEntity, Long> _lastHurt = new WeakHashMap<LivingEntity, Long>(); private WeakHashMap<LivingEntity, Long> _lastHurt = new WeakHashMap<LivingEntity, Long>();
private long _lastHurtByOther = 0; private WeakHashMap<LivingEntity, Long> _lastHurtBy = new WeakHashMap<LivingEntity, Long>();
public LinkedList<CombatLog> GetKills() public LinkedList<CombatLog> GetKills()
{ {
@ -31,12 +31,18 @@ public class ClientCombat
public boolean CanBeHurtBy(LivingEntity damager) public boolean CanBeHurtBy(LivingEntity damager)
{ {
if (damager != null) if (damager == null)
return true; return true;
if (System.currentTimeMillis() - _lastHurtByOther > 250) if (!_lastHurtBy.containsKey(damager))
{ {
_lastHurtByOther = System.currentTimeMillis(); _lastHurtBy.put(damager, System.currentTimeMillis());
return true;
}
if (System.currentTimeMillis() - _lastHurtBy.get(damager) > 400)
{
_lastHurtBy.put(damager, System.currentTimeMillis());
return true; return true;
} }

View File

@ -102,7 +102,6 @@ public class DamageManager extends MiniPlugin
NewDamageEvent(damagee, damager, projectile, event.getCause(), event.getDamage(), true, false, false, null, null, preCancel); NewDamageEvent(damagee, damager, projectile, event.getCause(), event.getDamage(), true, false, false, null, null, preCancel);
event.setCancelled(true); event.setCancelled(true);
System.out.println("Cancelled original");
} }
/* /*
@ -332,7 +331,6 @@ public class DamageManager extends MiniPlugin
return; return;
} }
System.out.println("Applying damage (" + (damage - entityDamagee.lastDamage) + ")");
ApplyDamage(entityDamagee, damage - entityDamagee.lastDamage, ignoreArmor); ApplyDamage(entityDamagee, damage - entityDamagee.lastDamage, ignoreArmor);
entityDamagee.lastDamage = damage; entityDamagee.lastDamage = damage;
} }
@ -341,7 +339,6 @@ public class DamageManager extends MiniPlugin
entityDamagee.lastDamage = damage; entityDamagee.lastDamage = damage;
entityDamagee.ax = entityDamagee.getHealth(); entityDamagee.ax = entityDamagee.getHealth();
//entityDamagee.noDamageTicks = entityDamagee.maxNoDamageTicks; //entityDamagee.noDamageTicks = entityDamagee.maxNoDamageTicks;
System.out.println("Applying damage (" + (damage - entityDamagee.lastDamage) + ")");
ApplyDamage(entityDamagee, damage, ignoreArmor); ApplyDamage(entityDamagee, damage, ignoreArmor);
//entityDamagee.hurtTicks = entityDamagee.aW = 10; //entityDamagee.hurtTicks = entityDamagee.aW = 10;
} }