Fixed fortitude healing too much
This commit is contained in:
parent
a67842b504
commit
cd4d2c16a8
@ -1,6 +1,8 @@
|
||||
package mineplex.minecraft.game.classcombat.Skill.Knight;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,7 +23,7 @@ import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
public class Fortitude extends Skill
|
||||
{
|
||||
private WeakHashMap<Player, Double> _preHealth = new WeakHashMap<Player, Double>();
|
||||
private WeakHashMap<Player, Integer> _health = new WeakHashMap<Player, Integer>();
|
||||
private WeakHashMap<Player, Double> _health = new WeakHashMap<Player, Double>();
|
||||
private WeakHashMap<Player, Long> _last = new WeakHashMap<Player, Long>();
|
||||
|
||||
public Fortitude(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels)
|
||||
@ -34,7 +36,7 @@ public class Fortitude extends Skill
|
||||
"up to #0#1 of the health you lost.",
|
||||
"",
|
||||
"You restore health at a rate of",
|
||||
"1 health per #3.5#-0.5 seconds.",
|
||||
"1 health per #3#-0.5 seconds.",
|
||||
"",
|
||||
"This does not stack, and is reset if",
|
||||
"you are hit again."
|
||||
@ -74,7 +76,7 @@ public class Fortitude extends Skill
|
||||
|
||||
double diff = _preHealth.remove(damagee) - damagee.getHealth();
|
||||
|
||||
_health.put(damagee, Math.min(level,(int)(diff + 0.5)));
|
||||
_health.put(damagee, Math.min(level, diff));
|
||||
_last.put(damagee, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@ -84,33 +86,35 @@ public class Fortitude extends Skill
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
HashSet<Player> remove = new HashSet<Player>();
|
||||
Iterator<Entry<Player, Double>> healthIterator = _health.entrySet().iterator();
|
||||
|
||||
for (Player cur : _health.keySet())
|
||||
while (healthIterator.hasNext())
|
||||
{
|
||||
int level = getLevel(cur);
|
||||
if (level == 0) continue;
|
||||
Entry<Player, Double> entry = healthIterator.next();
|
||||
|
||||
if (UtilTime.elapsed(_last.get(cur), 3500 - (500 * level)))
|
||||
{
|
||||
_health.put(cur, _health.get(cur) - 1);
|
||||
_last.put(cur, System.currentTimeMillis());
|
||||
int level = getLevel(entry.getKey());
|
||||
if (level == 0)
|
||||
continue;
|
||||
|
||||
if (_health.get(cur) <= 0)
|
||||
remove.add(cur);
|
||||
if (!UtilTime.elapsed(_last.get(entry.getKey()), 3000 - (500 * level)))
|
||||
continue;
|
||||
|
||||
//Heal
|
||||
UtilPlayer.health(cur, 1);
|
||||
//Work out healing
|
||||
double toHeal = Math.min(entry.getValue(), 1);
|
||||
entry.setValue(entry.getValue() - toHeal);
|
||||
|
||||
//Effect
|
||||
UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation(), 0, 0.2f, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
//Heal
|
||||
UtilPlayer.health(entry.getKey(), toHeal);
|
||||
|
||||
for (Player cur : remove)
|
||||
{
|
||||
_health.remove(cur);
|
||||
_last.remove(cur);
|
||||
//Effect
|
||||
UtilParticle.PlayParticle(ParticleType.HEART, entry.getKey().getEyeLocation(), 0, 0.2f, 0, 0, 1);
|
||||
|
||||
//Finished
|
||||
if (entry.getValue() <= 0)
|
||||
healthIterator.remove();
|
||||
|
||||
//Last Tick
|
||||
_last.put(entry.getKey(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user