mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-28 05:45:10 -06:00
Fixed XP allocation when using the last unit of ranged ammo
This commit is contained in:
parent
c84539003f
commit
73840f7c28
4 changed files with 16 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue