forked from 2009Scape/Server
Ensure damage can never exceed victim's remaining HP
This commit is contained in:
parent
5f62f5848a
commit
820ca5aba5
3 changed files with 8 additions and 0 deletions
|
|
@ -86,6 +86,8 @@ open class MagicSwingHandler
|
|||
if (spell!!.type === SpellType.BLITZ) {
|
||||
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)
|
||||
return ticks
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ open class MeleeSwingHandler
|
|||
hit = RandomFunction.random(max)
|
||||
}
|
||||
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)
|
||||
return 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ open class RangeSwingHandler
|
|||
if (entity == null || victim!!.location == null) {
|
||||
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)
|
||||
addExperience(entity, victim, state)
|
||||
return 1 + ceil(entity.location.getDistance(victim.location) * 0.3).toInt()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue