mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Corrected diamond bolts (e) effect
Removed inauthentic Verac armour effect of +1 max hit increase
This commit is contained in:
parent
45fb89ec73
commit
fb9d6307b3
6 changed files with 38 additions and 34 deletions
|
|
@ -31,10 +31,14 @@ import kotlin.math.floor
|
||||||
* Handles a combat swing.
|
* Handles a combat swing.
|
||||||
* @author Emperor
|
* @author Emperor
|
||||||
* @author Ceikry - Kotlin refactoring, general cleanup
|
* @author Ceikry - Kotlin refactoring, general cleanup
|
||||||
|
* @author Player Name - converted `flags` to ArrayList
|
||||||
*/
|
*/
|
||||||
abstract class CombatSwingHandler(var type: CombatStyle?) {
|
abstract class CombatSwingHandler(var type: CombatStyle?) {
|
||||||
var flags: Array<out SwingHandlerFlag> = emptyArray()
|
var flags: ArrayList<SwingHandlerFlag> = ArrayList(SwingHandlerFlag.values().size)
|
||||||
constructor(type: CombatStyle?, vararg flags: SwingHandlerFlag) : this(type) { this.flags = flags }
|
constructor(type: CombatStyle?, vararg flags: SwingHandlerFlag) : this(type) {
|
||||||
|
this.flags = arrayListOf(*flags)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mapping of the special attack handlers.
|
* The mapping of the special attack handlers.
|
||||||
*/
|
*/
|
||||||
|
|
@ -664,5 +668,6 @@ enum class SwingHandlerFlag {
|
||||||
IGNORE_STAT_BOOSTS_DAMAGE,
|
IGNORE_STAT_BOOSTS_DAMAGE,
|
||||||
IGNORE_STAT_BOOSTS_ACCURACY,
|
IGNORE_STAT_BOOSTS_ACCURACY,
|
||||||
IGNORE_PRAYER_BOOSTS_DAMAGE,
|
IGNORE_PRAYER_BOOSTS_DAMAGE,
|
||||||
IGNORE_PRAYER_BOOSTS_ACCURACY
|
IGNORE_PRAYER_BOOSTS_ACCURACY,
|
||||||
|
IGNORE_STAT_REDUCTION
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,16 +64,16 @@ open class MeleeSwingHandler (vararg flags: SwingHandlerFlag)
|
||||||
if (entity is Player) {
|
if (entity is Player) {
|
||||||
state.weapon = Weapon(entity.equipment[3])
|
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
|
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)
|
var max = calculateHit(entity, victim, 1.0)
|
||||||
if (victim != null) {
|
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
|
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
|
state.estimatedHit = hit
|
||||||
if(victim != null) {
|
if(victim != null) {
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,10 @@ import kotlin.math.floor
|
||||||
* @author Emperor
|
* @author Emperor
|
||||||
* @author Ceikry, conversion to Kotlin + cleanup
|
* @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}.
|
* Constructs a new `RangeSwingHandler` {@Code Object}.
|
||||||
*/
|
*/
|
||||||
: CombatSwingHandler(CombatStyle.RANGE, *flags) {
|
|
||||||
override fun canSwing(entity: Entity, victim: Entity): InteractionType? {
|
override fun canSwing(entity: Entity, victim: Entity): InteractionType? {
|
||||||
if (!isProjectileClipped(entity, victim, false)) {
|
if (!isProjectileClipped(entity, victim, false)) {
|
||||||
return InteractionType.NO_INTERACT
|
return InteractionType.NO_INTERACT
|
||||||
|
|
@ -75,8 +74,17 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
var hit = 0
|
var hit = 0
|
||||||
if (isAccurateImpact(entity, victim, CombatStyle.RANGE)) {
|
val armourPierce = state.ammunition != null && state.ammunition.effect != null && state.ammunition.effect == BoltEffect.DIAMOND && state.ammunition.effect.canFire(state)
|
||||||
val max = calculateHit(entity, victim, 1.0).also { if(entity?.name?.toLowerCase() == "test10") log(this::class.java, Log.FINE, "Damage: $it") }
|
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
|
state.maximumHit = max
|
||||||
hit = RandomFunction.random(max + 1)
|
hit = RandomFunction.random(max + 1)
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +132,7 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
|
||||||
if (state.ammunition != null && entity is Player) {
|
if (state.ammunition != null && entity is Player) {
|
||||||
val damage = state.ammunition.poisonDamage
|
val damage = state.ammunition.poisonDamage
|
||||||
if (state.estimatedHit > 0 && damage > 8 && RandomFunction.random(10) < 4) {
|
if (state.estimatedHit > 0 && damage > 8 && RandomFunction.random(10) < 4) {
|
||||||
applyPoison (victim, entity, damage)
|
applyPoison(victim, entity, damage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.adjustBattleState(entity, victim, state)
|
super.adjustBattleState(entity, victim, state)
|
||||||
|
|
@ -161,7 +169,7 @@ open class RangeSwingHandler (vararg flags: SwingHandlerFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun impact(entity: Entity?, victim: Entity?, state: BattleState?) {
|
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)
|
state.ammunition.effect.impact(state)
|
||||||
}
|
}
|
||||||
val hit = state.estimatedHit
|
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)
|
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]
|
styleStrengthBonus -= entity.equipment[EquipmentContainer.SLOT_ARROWS].definition.getConfiguration<IntArray>(ItemConfigParser.BONUS)[14]
|
||||||
var effectiveStrengthLevel = entity.skills.getLevel(Skills.RANGE).toDouble()
|
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))
|
effectiveStrengthLevel = floor(effectiveStrengthLevel + (entity.prayer.getSkillBonus(Skills.RANGE) * effectiveStrengthLevel))
|
||||||
if(entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) effectiveStrengthLevel += 3
|
if(entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) effectiveStrengthLevel += 3
|
||||||
effectiveStrengthLevel += 8
|
effectiveStrengthLevel += 8
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public final class Ammunition {
|
||||||
* Loads all the {@code Ammunition} info to the mapping.
|
* Loads all the {@code Ammunition} info to the mapping.
|
||||||
* @return {@code True}.
|
* @return {@code True}.
|
||||||
*/
|
*/
|
||||||
public static final boolean initialize() {
|
public static boolean initialize() {
|
||||||
Document doc;
|
Document doc;
|
||||||
try {
|
try {
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
|
@ -141,7 +141,7 @@ public final class Ammunition {
|
||||||
* @param id The ammo id.
|
* @param id The ammo id.
|
||||||
* @return The ammunition object.
|
* @return The ammunition object.
|
||||||
*/
|
*/
|
||||||
public static final Ammunition get(int id) {
|
public static Ammunition get(int id) {
|
||||||
return AMMUNITION.get(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.
|
* @param effect the effect to set.
|
||||||
*/
|
*/
|
||||||
public void setEffect(BoltEffect effect) {
|
public void setEffect(BoltEffect effect) {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import static core.api.ContentAPIKt.*;
|
||||||
*/
|
*/
|
||||||
public enum BoltEffect {
|
public enum BoltEffect {
|
||||||
OPAL(9236, Graphics.create(749), new Audio(2918)) {
|
OPAL(9236, Graphics.create(749), new Audio(2918)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void impact(BattleState state) {
|
public void impact(BattleState state) {
|
||||||
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(3, 20));
|
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(3, 20));
|
||||||
|
|
@ -33,7 +32,6 @@ public enum BoltEffect {
|
||||||
|
|
||||||
},
|
},
|
||||||
JADE(9237, new Graphics(755), new Audio(2916)) {
|
JADE(9237, new Graphics(755), new Audio(2916)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void impact(BattleState state) {
|
public void impact(BattleState state) {
|
||||||
if (state.getVictim() instanceof Player) {
|
if (state.getVictim() instanceof Player) {
|
||||||
|
|
@ -59,7 +57,6 @@ public enum BoltEffect {
|
||||||
|
|
||||||
},
|
},
|
||||||
PEARL(9238, Graphics.create(750), new Audio(2920)) {
|
PEARL(9238, Graphics.create(750), new Audio(2920)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void impact(BattleState state) {
|
public void impact(BattleState state) {
|
||||||
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(3, 20));
|
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(3, 20));
|
||||||
|
|
@ -113,7 +110,6 @@ public enum BoltEffect {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RUBY(9242, new Graphics(754), new Audio(2911, 1)) { // in this case, volume is the number of times to play the sound...
|
RUBY(9242, new Graphics(754), new Audio(2911, 1)) { // in this case, volume is the number of times to play the sound...
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void impact(BattleState state) { // hit target for 20% of their HP, hit self for 10% of HP
|
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);
|
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;
|
return super.canFire(state) && state.getAttacker().getSkills().getLifepoints() - playerPoints >= 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DIAMOND(9243, new Graphics(758), new Audio(2913)) {
|
DIAMOND(9243, new Graphics(758), new Audio(2913)) { /* handled in RangeSwingHandler.kt::swing(entity: Entity?, victim: Entity?, state: BattleState?) */ },
|
||||||
@Override
|
|
||||||
public void impact(BattleState state) {
|
|
||||||
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(5, 14)); // unauthentic, needs fixing
|
|
||||||
super.impact(state);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DRAGON(9244, new Graphics(756), new Audio(2915)) {
|
DRAGON(9244, new Graphics(756), new Audio(2915)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void impact(BattleState state) {
|
public void impact(BattleState state) {
|
||||||
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(17, 29));
|
state.setEstimatedHit(state.getEstimatedHit() + RandomFunction.random(17, 29));
|
||||||
|
|
@ -165,10 +154,8 @@ public enum BoltEffect {
|
||||||
}
|
}
|
||||||
return super.canFire(state);
|
return super.canFire(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
ONYX(9245, new Graphics(753), new Audio(2917)) {
|
ONYX(9245, new Graphics(753), new Audio(2917)) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void impact(BattleState state) {
|
public void impact(BattleState state) {
|
||||||
int newDamage = (int) (state.getEstimatedHit() * 0.25);
|
int newDamage = (int) (state.getEstimatedHit() * 0.25);
|
||||||
|
|
@ -270,5 +257,4 @@ public enum BoltEffect {
|
||||||
public int getItemId() {
|
public int getItemId() {
|
||||||
return itemId;
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.combat.equipment.RangeWeapon
|
||||||
import core.game.node.entity.impl.Projectile
|
import core.game.node.entity.impl.Projectile
|
||||||
import core.game.node.entity.npc.NPC
|
import core.game.node.entity.npc.NPC
|
||||||
import core.tools.SystemLogger
|
|
||||||
import core.game.world.map.Location
|
import core.game.world.map.Location
|
||||||
import core.game.world.update.flag.context.Animation
|
import core.game.world.update.flag.context.Animation
|
||||||
import core.game.world.update.flag.context.Graphics
|
import core.game.world.update.flag.context.Graphics
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue