Fixed XP allocation when using the last unit of ranged ammo
This commit is contained in:
@@ -431,6 +431,7 @@ class CombatPulse(
|
||||
}
|
||||
handler.adjustBattleState(entity, victim!!, state)
|
||||
handler.addExperience(entity, victim, state)
|
||||
handler.postSwing(entity, victim, state)
|
||||
handler.visualize(entity, victim, state)
|
||||
if (delay - 1 < 1) {
|
||||
handler.visualizeImpact(entity, victim, state)
|
||||
|
||||
@@ -531,6 +531,12 @@ abstract class CombatSwingHandler(var type: CombatStyle?) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for operations that conceptually happen during swing but could mess with experience granting logic if they
|
||||
* happened earlier.
|
||||
*/
|
||||
open fun postSwing(entity: Entity?, victim: Entity?, state: BattleState?) {}
|
||||
|
||||
/**
|
||||
* Gets the formated hit.
|
||||
* @param attacker The attacking entity.
|
||||
|
||||
@@ -119,6 +119,9 @@ open class MultiSwingHandler(meleeDistance: Boolean, vararg attacks: SwitchAttac
|
||||
override fun addExperience(entity: Entity?, victim: Entity?, state: BattleState?) {
|
||||
current.handler.addExperience(entity, victim, state)
|
||||
}
|
||||
override fun postSwing(entity: Entity?, victim: Entity?, state: BattleState?) {
|
||||
current.handler.postSwing(entity, victim, state)
|
||||
}
|
||||
override fun visualizeImpact(entity: Entity?, victim: Entity?, state: BattleState?) {
|
||||
if (current.isUseHandler) {
|
||||
current.handler.visualizeImpact(entity, victim, state)
|
||||
|
||||
@@ -101,10 +101,15 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag) : CombatSwingHandl
|
||||
}
|
||||
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)
|
||||
return 1 + ceil(entity.location.getDistance(victim.location) * 0.3).toInt()
|
||||
}
|
||||
|
||||
override fun postSwing(entity: Entity?, victim: Entity?, state: BattleState?) {
|
||||
// Using the last piece of ammo in swing causes experience calculations to assume we're using unarmed combat
|
||||
// which gives wrong experience values. Delay ammo consumption until later to avoid this problem.
|
||||
useAmmo(entity!!, state!!, victim!!.location)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the range data.
|
||||
* @param entity The entity.
|
||||
|
||||
Reference in New Issue
Block a user