Ensure damage can never exceed victim's remaining HP
This commit is contained in:
@@ -86,6 +86,8 @@ open class MagicSwingHandler
|
|||||||
if (spell!!.type === SpellType.BLITZ) {
|
if (spell!!.type === SpellType.BLITZ) {
|
||||||
ticks++
|
ticks++
|
||||||
}
|
}
|
||||||
|
if(state.estimatedHit > victim.skills.lifepoints) state.estimatedHit = victim.skills.lifepoints
|
||||||
|
if(state.estimatedHit + state.secondaryHit > victim.skills.lifepoints) state.secondaryHit -= ((state.estimatedHit + state.secondaryHit) - victim.skills.lifepoints)
|
||||||
addExperience(entity, victim, state)
|
addExperience(entity, victim, state)
|
||||||
return ticks
|
return ticks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ open class MeleeSwingHandler
|
|||||||
hit = RandomFunction.random(max)
|
hit = RandomFunction.random(max)
|
||||||
}
|
}
|
||||||
state.estimatedHit = hit
|
state.estimatedHit = hit
|
||||||
|
if(victim != null) {
|
||||||
|
if (state.estimatedHit > victim.skills.lifepoints) state.estimatedHit = victim.skills.lifepoints
|
||||||
|
if (state.estimatedHit + state.secondaryHit > victim.skills.lifepoints) state.secondaryHit -= ((state.estimatedHit + state.secondaryHit) - victim.skills.lifepoints)
|
||||||
|
}
|
||||||
addExperience(entity, victim, state)
|
addExperience(entity, victim, state)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ open class RangeSwingHandler
|
|||||||
if (entity == null || victim!!.location == null) {
|
if (entity == null || victim!!.location == null) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
if(state.estimatedHit > victim.skills.lifepoints) state.estimatedHit = victim.skills.lifepoints
|
||||||
|
if(state.estimatedHit + state.secondaryHit > victim.skills.lifepoints) state.secondaryHit -= ((state.estimatedHit + state.secondaryHit) - victim.skills.lifepoints)
|
||||||
useAmmo(entity, state, victim.location)
|
useAmmo(entity, state, victim.location)
|
||||||
addExperience(entity, victim, state)
|
addExperience(entity, victim, state)
|
||||||
return 1 + ceil(entity.location.getDistance(victim.location) * 0.3).toInt()
|
return 1 + ceil(entity.location.getDistance(victim.location) * 0.3).toInt()
|
||||||
|
|||||||
Reference in New Issue
Block a user