Fixed accuracy calculations.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package rs09.game.node.entity.combat.handlers
|
package rs09.game.node.entity.combat.handlers
|
||||||
|
|
||||||
import core.game.container.Container
|
import api.ContentAPI
|
||||||
|
import api.EquipmentSlot
|
||||||
import core.game.container.impl.EquipmentContainer
|
import core.game.container.impl.EquipmentContainer
|
||||||
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
|
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
|
||||||
import core.game.content.quest.tutorials.tutorialisland.TutorialStage
|
import core.game.content.quest.tutorials.tutorialisland.TutorialStage
|
||||||
@@ -18,7 +19,6 @@ import core.game.node.entity.state.EntityState
|
|||||||
import core.game.world.map.path.Pathfinder
|
import core.game.world.map.path.Pathfinder
|
||||||
import core.tools.RandomFunction
|
import core.tools.RandomFunction
|
||||||
import rs09.game.node.entity.combat.CombatSwingHandler
|
import rs09.game.node.entity.combat.CombatSwingHandler
|
||||||
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks
|
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +72,7 @@ open class MeleeSwingHandler
|
|||||||
if (state.armourEffect === ArmourSet.VERAC || isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
|
if (state.armourEffect === ArmourSet.VERAC || isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
|
||||||
val max = calculateHit(entity, victim, 1.0)
|
val max = calculateHit(entity, victim, 1.0)
|
||||||
state.maximumHit = max
|
state.maximumHit = max
|
||||||
hit = RandomFunction.random(max)
|
hit = RandomFunction.random(max + 1)
|
||||||
}
|
}
|
||||||
state.estimatedHit = hit
|
state.estimatedHit = hit
|
||||||
if(victim != null) {
|
if(victim != null) {
|
||||||
@@ -137,46 +137,36 @@ open class MeleeSwingHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun calculateAccuracy(entity: Entity?): Int {
|
override fun calculateAccuracy(entity: Entity?): Int {
|
||||||
val baseLevel = entity!!.skills.getStaticLevel(Skills.ATTACK)
|
//formula taken from wiki: https://oldschool.runescape.wiki/w/Damage_per_second/Melee#Step_six:_Calculate_the_hit_chance Yes I know it's old school. It's the best resource we have for potentially authentic formulae.
|
||||||
var weaponRequirement = baseLevel
|
entity ?: return 0
|
||||||
if (entity is Player) {
|
var effectiveAttackLevel = entity.skills.getLevel(Skills.ATTACK).toDouble()
|
||||||
val weapon = entity.equipment[3]
|
if(entity is Player) effectiveAttackLevel = floor(effectiveAttackLevel + (entity.prayer.getSkillBonus(Skills.ATTACK) * effectiveAttackLevel))
|
||||||
weaponRequirement = weapon?.definition?.getRequirement(Skills.ATTACK) ?: 1
|
if(entity.properties.attackStyle.style == WeaponInterface.STYLE_ACCURATE) effectiveAttackLevel += 3
|
||||||
|
else if(entity.properties.attackStyle.style == WeaponInterface.STYLE_CONTROLLED) effectiveAttackLevel += 1
|
||||||
|
effectiveAttackLevel += 8
|
||||||
|
if(entity is Player && entity.isWearingVoid(true)) effectiveAttackLevel *= 1.1
|
||||||
|
effectiveAttackLevel = floor(effectiveAttackLevel)
|
||||||
|
effectiveAttackLevel *= (entity.properties.bonuses[entity.properties.attackStyle.bonusType] + 64)
|
||||||
|
|
||||||
|
val helmetName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.HAT)?.name ?: "null" else "null").toLowerCase()
|
||||||
|
val amuletName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.AMULET)?.name ?: "null" else "null").toLowerCase()
|
||||||
|
val victimName = entity.properties.combatPulse.getVictim()?.name ?: "none"
|
||||||
|
|
||||||
|
if (entity is Player //Slayer helm/ black mask
|
||||||
|
&& (helmetName.contains("black mask") || helmetName.contains("slayer helm"))
|
||||||
|
&& entity.slayer.task?.ids?.contains((entity.properties.combatPulse.getVictim()?.id ?: 0)) == true
|
||||||
|
) {
|
||||||
|
effectiveAttackLevel *= 1.2
|
||||||
}
|
}
|
||||||
var weaponBonus = 0.0
|
|
||||||
if (baseLevel > weaponRequirement) {
|
else if (entity is Player //Salve amulet
|
||||||
weaponBonus = (baseLevel - weaponRequirement) * .3
|
&& (amuletName.contains("salve"))
|
||||||
|
&& checkUndead(victimName)
|
||||||
|
) {
|
||||||
|
effectiveAttackLevel *= 1.2
|
||||||
}
|
}
|
||||||
val style = entity.properties.attackStyle
|
|
||||||
var level = entity.skills.getLevel(Skills.ATTACK)
|
return floor(effectiveAttackLevel).toInt()
|
||||||
if(entity is Player && SkillcapePerks.isActive(SkillcapePerks.PRECISION_STRIKES,entity.asPlayer())){
|
|
||||||
level += 6
|
|
||||||
}
|
|
||||||
var prayer = 1.0
|
|
||||||
if (entity is Player) {
|
|
||||||
prayer += entity.prayer.getSkillBonus(Skills.ATTACK)
|
|
||||||
}
|
|
||||||
var additional = 1.0 // Black mask/slayer helmet/salve/...
|
|
||||||
if (entity.properties.combatPulse.getVictim() != null) {
|
|
||||||
if (!entity.properties.combatPulse.getVictim()!!.isPlayer && entity is Player) {
|
|
||||||
if (checkUndead(entity.getProperties().combatPulse.getVictim()!!.name) && entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET] != null) {
|
|
||||||
if (entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET].id == 10588) {
|
|
||||||
additional += 0.20
|
|
||||||
} else if (entity.isPlayer() && entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET].id == 4081) {
|
|
||||||
additional += 0.15
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var styleBonus = 0
|
|
||||||
if (style.style == WeaponInterface.STYLE_ACCURATE) {
|
|
||||||
styleBonus = 3
|
|
||||||
} else if (style.style == WeaponInterface.STYLE_CONTROLLED) {
|
|
||||||
styleBonus = 1
|
|
||||||
}
|
|
||||||
val effective = floor(level * prayer * additional + styleBonus + weaponBonus)
|
|
||||||
val bonus = entity.properties.bonuses[style.bonusType]
|
|
||||||
return floor((effective + 8) * (bonus + 64) / 10 * 1.10).toInt()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun calculateHit(entity: Entity?, victim: Entity?, modifier: Double): Int {
|
override fun calculateHit(entity: Entity?, victim: Entity?, modifier: Double): Int {
|
||||||
@@ -198,22 +188,29 @@ open class MeleeSwingHandler
|
|||||||
return (1.3 + (cumulativeStr / 10) + (bonus / 80) + ((cumulativeStr * bonus) / 640)).toInt()
|
return (1.3 + (cumulativeStr / 10) + (bonus / 80) + ((cumulativeStr * bonus) / 640)).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun calculateDefence(entity: Entity?, attacker: Entity?): Int {
|
override fun calculateDefence(victim: Entity?, attacker: Entity?): Int {
|
||||||
val style = entity!!.properties.attackStyle
|
//authentic formula, taken from OSRS wiki: https://oldschool.runescape.wiki/w/Damage_per_second/Melee#Step_five:_Calculate_the_Defence_roll
|
||||||
var styleBonus = 0
|
victim ?: return 0
|
||||||
if (style.style == WeaponInterface.STYLE_DEFENSIVE || style.style == WeaponInterface.STYLE_LONG_RANGE) {
|
attacker ?: return 0
|
||||||
styleBonus = 3
|
|
||||||
} else if (style.style == WeaponInterface.STYLE_CONTROLLED) {
|
when(victim){
|
||||||
styleBonus = 1
|
is Player -> {
|
||||||
|
var effectiveDefenceLevel = victim.skills.getLevel(Skills.DEFENCE).toDouble()
|
||||||
|
effectiveDefenceLevel = floor(effectiveDefenceLevel + (victim.prayer.getSkillBonus(Skills.DEFENCE) * effectiveDefenceLevel))
|
||||||
|
if(victim.properties.attackStyle.style == WeaponInterface.STYLE_DEFENSIVE) effectiveDefenceLevel += 3
|
||||||
|
else if(victim.properties.attackStyle.style == WeaponInterface.STYLE_CONTROLLED) effectiveDefenceLevel += 1
|
||||||
|
effectiveDefenceLevel += 8
|
||||||
|
effectiveDefenceLevel = floor(effectiveDefenceLevel)
|
||||||
|
return floor(effectiveDefenceLevel * (victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64)).toInt()
|
||||||
}
|
}
|
||||||
val level = entity.skills.getLevel(Skills.DEFENCE)
|
is NPC -> {
|
||||||
var prayer = 1.0
|
val defLevel = victim.skills.getLevel(Skills.DEFENCE)
|
||||||
if (entity is Player) {
|
val styleDefenceBonus = victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64
|
||||||
prayer += entity.prayer.getSkillBonus(Skills.DEFENCE)
|
return defLevel * styleDefenceBonus
|
||||||
}
|
}
|
||||||
val effective = floor(level * prayer + styleBonus)
|
}
|
||||||
val equipment = entity.properties.bonuses[attacker!!.properties.attackStyle.bonusType + 5]
|
|
||||||
return floor((effective + 8) * (equipment + 64) / 10).toInt()
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSetMultiplier(e: Entity?, skillId: Int): Double {
|
override fun getSetMultiplier(e: Entity?, skillId: Int): Double {
|
||||||
@@ -221,19 +218,6 @@ open class MeleeSwingHandler
|
|||||||
// System.out.println("Fiist number -> " + 1.0 + ((e.getSkills().getMaximumLifepoints() - e.getSkills().getLifepoints()) * 0.01));
|
// System.out.println("Fiist number -> " + 1.0 + ((e.getSkills().getMaximumLifepoints() - e.getSkills().getLifepoints()) * 0.01));
|
||||||
return 1.0 + (e!!.skills.maximumLifepoints - e.skills.lifepoints) * 0.01
|
return 1.0 + (e!!.skills.maximumLifepoints - e.skills.lifepoints) * 0.01
|
||||||
}
|
}
|
||||||
if (e is Player) {
|
|
||||||
val c: Container = e.equipment
|
|
||||||
val itemId = c.getNew(EquipmentContainer.SLOT_HAT).id
|
|
||||||
if ((skillId == Skills.ATTACK || skillId == Skills.STRENGTH) && (itemId in 8901..8921 || itemId == 13263)) {
|
|
||||||
val victim = e.getProperties().combatPulse.getVictim()
|
|
||||||
if (victim is NPC && victim.task == e.slayer.task) {
|
|
||||||
return 1.15
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (containsVoidSet(c) && c.getNew(EquipmentContainer.SLOT_HAT).id == 11665) {
|
|
||||||
return 1.1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1.0
|
return 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user