Corrected diamond bolts (e) effect

Removed inauthentic Verac armour effect of +1 max hit increase
This commit is contained in:
Player Name 2025-02-18 04:32:21 +00:00 committed by Ryan
parent 45fb89ec73
commit fb9d6307b3
6 changed files with 38 additions and 34 deletions

View file

@ -31,10 +31,14 @@ import kotlin.math.floor
* Handles a combat swing.
* @author Emperor
* @author Ceikry - Kotlin refactoring, general cleanup
* @author Player Name - converted `flags` to ArrayList
*/
abstract class CombatSwingHandler(var type: CombatStyle?) {
var flags: Array<out SwingHandlerFlag> = emptyArray()
constructor(type: CombatStyle?, vararg flags: SwingHandlerFlag) : this(type) { this.flags = flags }
var flags: ArrayList<SwingHandlerFlag> = ArrayList(SwingHandlerFlag.values().size)
constructor(type: CombatStyle?, vararg flags: SwingHandlerFlag) : this(type) {
this.flags = arrayListOf(*flags)
}
/**
* The mapping of the special attack handlers.
*/
@ -664,5 +668,6 @@ enum class SwingHandlerFlag {
IGNORE_STAT_BOOSTS_DAMAGE,
IGNORE_STAT_BOOSTS_ACCURACY,
IGNORE_PRAYER_BOOSTS_DAMAGE,
IGNORE_PRAYER_BOOSTS_ACCURACY
IGNORE_PRAYER_BOOSTS_ACCURACY,
IGNORE_STAT_REDUCTION
}

View file

@ -64,16 +64,16 @@ open class MeleeSwingHandler (vararg flags: SwingHandlerFlag)
if (entity is Player) {
state.weapon = Weapon(entity.equipment[3])
}
if (entity!!.properties.armourSet === ArmourSet.VERAC && RandomFunction.random(100) < 25) {
if (entity!!.properties.armourSet == ArmourSet.VERAC && RandomFunction.roll(4)) {
state.armourEffect = ArmourSet.VERAC
}
if (state.armourEffect === ArmourSet.VERAC || isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
if (state.armourEffect == ArmourSet.VERAC || isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
var max = calculateHit(entity, victim, 1.0)
if (victim != null) {
if (entity is NPC && state.armourEffect === ArmourSet.VERAC && victim.hasProtectionPrayer(CombatStyle.MELEE)) max = max * 2 / 3
if (entity is NPC && state.armourEffect == ArmourSet.VERAC && victim.hasProtectionPrayer(CombatStyle.MELEE)) max = max * 2 / 3
}
state.maximumHit = max
hit = RandomFunction.random(max + 1) + (if (entity is Player && state.armourEffect === ArmourSet.VERAC) 1 else 0)
hit = RandomFunction.random(max + 1)
}
state.estimatedHit = hit
if(victim != null) {

View file

@ -30,11 +30,10 @@ import kotlin.math.floor
* @author Emperor
* @author Ceikry, conversion to Kotlin + cleanup
*/
open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
open class RangeSwingHandler (vararg flags: SwingHandlerFlag) : CombatSwingHandler(CombatStyle.RANGE, *flags) {
/**
* Constructs a new `RangeSwingHandler` {@Code Object}.
*/
: CombatSwingHandler(CombatStyle.RANGE, *flags) {
override fun canSwing(entity: Entity, victim: Entity): InteractionType? {
if (!isProjectileClipped(entity, victim, false)) {
return InteractionType.NO_INTERACT
@ -75,8 +74,17 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
return -1
}
var hit = 0
if (isAccurateImpact(entity, victim, CombatStyle.RANGE)) {
val max = calculateHit(entity, victim, 1.0).also { if(entity?.name?.toLowerCase() == "test10") log(this::class.java, Log.FINE, "Damage: $it") }
val armourPierce = state.ammunition != null && state.ammunition.effect != null && state.ammunition.effect == BoltEffect.DIAMOND && state.ammunition.effect.canFire(state)
if (armourPierce || isAccurateImpact(entity, victim, CombatStyle.RANGE)) {
val max: Int
if (armourPierce) {
state.ammunition.effect.impact(state)
flags.add(SwingHandlerFlag.IGNORE_STAT_REDUCTION)
max = (calculateHit(entity, victim, 1.0) * 1.15).toInt()
flags.remove(SwingHandlerFlag.IGNORE_STAT_REDUCTION)
} else {
max = calculateHit(entity, victim, 1.0)
}
state.maximumHit = max
hit = RandomFunction.random(max + 1)
}
@ -124,7 +132,7 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
if (state.ammunition != null && entity is Player) {
val damage = state.ammunition.poisonDamage
if (state.estimatedHit > 0 && damage > 8 && RandomFunction.random(10) < 4) {
applyPoison (victim, entity, damage)
applyPoison(victim, entity, damage)
}
}
super.adjustBattleState(entity, victim, state)
@ -161,7 +169,7 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
}
override fun impact(entity: Entity?, victim: Entity?, state: BattleState?) {
if (state!!.ammunition != null && state.ammunition.effect != null && state.ammunition.effect.canFire(state)) {
if (state!!.ammunition != null && state.ammunition.effect != null && state.ammunition.effect != BoltEffect.DIAMOND && state.ammunition.effect.canFire(state)) {
state.ammunition.effect.impact(state)
}
val hit = state.estimatedHit
@ -220,7 +228,13 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
if(entity.equipment[EquipmentContainer.SLOT_WEAPON] != null && RangeWeapon.get(entity.equipment[EquipmentContainer.SLOT_WEAPON].id).ammunitionSlot != EquipmentContainer.SLOT_ARROWS && entity.equipment[EquipmentContainer.SLOT_ARROWS] != null)
styleStrengthBonus -= entity.equipment[EquipmentContainer.SLOT_ARROWS].definition.getConfiguration<IntArray>(ItemConfigParser.BONUS)[14]
var effectiveStrengthLevel = entity.skills.getLevel(Skills.RANGE).toDouble()
if(!flags.contains(SwingHandlerFlag.IGNORE_PRAYER_BOOSTS_DAMAGE))
if (flags.contains(SwingHandlerFlag.IGNORE_STAT_REDUCTION)) {
val staticLevel = entity.skills.getStaticLevel(Skills.RANGE).toDouble()
if (staticLevel > effectiveStrengthLevel) {
effectiveStrengthLevel = staticLevel
}
}
if (!flags.contains(SwingHandlerFlag.IGNORE_PRAYER_BOOSTS_DAMAGE))
effectiveStrengthLevel = floor(effectiveStrengthLevel + (entity.prayer.getSkillBonus(Skills.RANGE) * effectiveStrengthLevel))
if(entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) effectiveStrengthLevel += 3
effectiveStrengthLevel += 8

View file

@ -74,7 +74,7 @@ public final class Ammunition {
* Loads all the {@code Ammunition} info to the mapping.
* @return {@code True}.
*/
public static final boolean initialize() {
public static boolean initialize() {
Document doc;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@ -141,7 +141,7 @@ public final class Ammunition {
* @param id The ammo id.
* @return The ammunition object.
*/
public static final Ammunition get(int id) {
public static Ammunition get(int id) {
return AMMUNITION.get(id);
}
@ -189,7 +189,7 @@ public final class Ammunition {
}
/**
* Sets the baeffect.
* Sets the effect.
* @param effect the effect to set.
*/
public void setEffect(BoltEffect effect) {

View file

@ -21,7 +21,6 @@ import static core.api.ContentAPIKt.*;
*/
public enum BoltEffect {
OPAL(9236, Graphics.create(749), new Audio(2918)) {
@Override
public void impact(BattleState state) {
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(3, 20));
@ -33,7 +32,6 @@ public enum BoltEffect {
},
JADE(9237, new Graphics(755), new Audio(2916)) {
@Override
public void impact(BattleState state) {
if (state.getVictim() instanceof Player) {
@ -59,7 +57,6 @@ public enum BoltEffect {
},
PEARL(9238, Graphics.create(750), new Audio(2920)) {
@Override
public void impact(BattleState state) {
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(3, 20));
@ -108,12 +105,11 @@ public enum BoltEffect {
EMERALD(9241, new Graphics(752), new Audio(2919)) {
@Override
public void impact(BattleState state) {
applyPoison(state.getVictim(), state.getAttacker(), 40);
applyPoison(state.getVictim(), state.getAttacker(), 40);
super.impact(state);
}
},
RUBY(9242, new Graphics(754), new Audio(2911, 1)) { // in this case, volume is the number of times to play the sound...
@Override
public void impact(BattleState state) { // hit target for 20% of their HP, hit self for 10% of HP
int victimPoints = (int) (state.getVictim().getSkills().getLifepoints() * 0.20);
@ -135,15 +131,8 @@ public enum BoltEffect {
return super.canFire(state) && state.getAttacker().getSkills().getLifepoints() - playerPoints >= 1;
}
},
DIAMOND(9243, new Graphics(758), new Audio(2913)) {
@Override
public void impact(BattleState state) {
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(5, 14)); // unauthentic, needs fixing
super.impact(state);
}
},
DIAMOND(9243, new Graphics(758), new Audio(2913)) { /* handled in RangeSwingHandler.kt::swing(entity: Entity?, victim: Entity?, state: BattleState?) */ },
DRAGON(9244, new Graphics(756), new Audio(2915)) {
@Override
public void impact(BattleState state) {
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(17, 29));
@ -165,10 +154,8 @@ public enum BoltEffect {
}
return super.canFire(state);
}
},
ONYX(9245, new Graphics(753), new Audio(2917)) {
@Override
public void impact(BattleState state) {
int newDamage = (int) (state.getEstimatedHit() * 0.25);
@ -270,5 +257,4 @@ public enum BoltEffect {
public int getItemId() {
return itemId;
}
}

View file

@ -8,7 +8,6 @@ import core.game.node.entity.combat.equipment.BoltEffect
import core.game.node.entity.combat.equipment.RangeWeapon
import core.game.node.entity.impl.Projectile
import core.game.node.entity.npc.NPC
import core.tools.SystemLogger
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics