Implemented authentic dragon axe special attack and enabled it by default, osrs style is toggle via worldprop world config dragon_axe_use_osrs_spec = true
This commit is contained in:
-65
@@ -1,65 +0,0 @@
|
|||||||
package content.global.handlers.item.equipment.special;
|
|
||||||
|
|
||||||
import core.game.node.entity.skill.Skills;
|
|
||||||
import core.game.node.entity.Entity;
|
|
||||||
import core.game.node.entity.combat.BattleState;
|
|
||||||
import core.game.node.entity.combat.CombatStyle;
|
|
||||||
import core.game.node.entity.combat.MeleeSwingHandler;
|
|
||||||
import core.game.node.entity.impl.Animator.Priority;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.game.world.update.flag.context.Graphics;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the Dragon axe special attack.
|
|
||||||
* @author Crash
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public final class ClobberSpecialHandler extends MeleeSwingHandler implements Plugin<Object> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The special energy required.
|
|
||||||
*/
|
|
||||||
private static final int SPECIAL_ENERGY = 100;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attack animation.
|
|
||||||
*/
|
|
||||||
private static final Animation ANIMATION = new Animation(2876, Priority.HIGH);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The graphic.
|
|
||||||
*/
|
|
||||||
private static final Graphics GRAPHIC = new Graphics(479, 96);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object fireEvent(String identifier, Object... args) {
|
|
||||||
switch (identifier) {
|
|
||||||
case "instant_spec":
|
|
||||||
case "ncspec":
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
CombatStyle.MELEE.getSwingHandler().register(6739, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int swing(Entity entity, Entity victim, BattleState state) {
|
|
||||||
Player p = (Player) entity;
|
|
||||||
if (!p.getSettings().drainSpecial(SPECIAL_ENERGY))
|
|
||||||
return -1;
|
|
||||||
p.sendChat("Chop chop!");
|
|
||||||
p.visualize(ANIMATION, GRAPHIC);
|
|
||||||
p.getSkills().updateLevel(Skills.WOODCUTTING, 3, p.getSkills().getStaticLevel(Skills.WOODCUTTING) + 3);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+122
@@ -0,0 +1,122 @@
|
|||||||
|
package content.global.handlers.item.equipment.special
|
||||||
|
|
||||||
|
import core.ServerConstants
|
||||||
|
import core.game.container.impl.EquipmentContainer
|
||||||
|
import core.game.node.entity.Entity
|
||||||
|
import core.game.node.entity.combat.BattleState
|
||||||
|
import core.game.node.entity.combat.CombatStyle
|
||||||
|
import core.game.node.entity.combat.MeleeSwingHandler
|
||||||
|
import core.game.node.entity.combat.equipment.Weapon
|
||||||
|
import core.game.node.entity.impl.Animator.Priority
|
||||||
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.node.entity.player.link.audio.Audio
|
||||||
|
import core.game.node.entity.skill.Skills
|
||||||
|
import core.game.node.item.Item
|
||||||
|
import core.game.world.update.flag.context.Animation
|
||||||
|
import core.game.world.update.flag.context.Graphics
|
||||||
|
import core.plugin.Initializable
|
||||||
|
import core.plugin.Plugin
|
||||||
|
import core.tools.RandomFunction
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the Dragon axe special attack.
|
||||||
|
* The OSRS special attack can be used instead by setting dragon_axe_use_osrs_spec server constant to true
|
||||||
|
* @author Crash
|
||||||
|
*/
|
||||||
|
@Initializable
|
||||||
|
class ClobberSpecialHandler : MeleeSwingHandler(), Plugin<Any> {
|
||||||
|
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||||
|
CombatStyle.MELEE.swingHandler.register(ITEM.id, this)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fireEvent(identifier: String, vararg args: Any): Any {
|
||||||
|
return if (ServerConstants.DRAGON_AXE_USE_OSRS_SPEC && identifier == "instant_spec") true else Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visualize(entity: Entity, victim: Entity?, state: BattleState?) {
|
||||||
|
entity.visualize(ANIMATION, GRAPHIC)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun swing(entity: Entity?, victim: Entity?, state: BattleState?): Int {
|
||||||
|
return if (ServerConstants.DRAGON_AXE_USE_OSRS_SPEC) {
|
||||||
|
swingOSRS(entity)
|
||||||
|
} else {
|
||||||
|
swingAuthentic(entity, victim, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://runescape.wiki/w/Dragon_hatchet?oldid=1107166
|
||||||
|
*/
|
||||||
|
private fun swingAuthentic(entity: Entity?, victim: Entity?, state: BattleState?): Int {
|
||||||
|
val player = entity as? Player ?: return -1
|
||||||
|
if (victim == null) return -1
|
||||||
|
if (state == null) return -1
|
||||||
|
if (!player.settings.drainSpecial(SPECIAL_ENERGY)) return -1
|
||||||
|
|
||||||
|
state.style = CombatStyle.MELEE
|
||||||
|
state.weapon = Weapon(player.equipment[EquipmentContainer.SLOT_WEAPON])
|
||||||
|
var hit = 0
|
||||||
|
if (isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
|
||||||
|
val max = calculateHit(entity, victim, 1.0)
|
||||||
|
state.maximumHit = max
|
||||||
|
hit = RandomFunction.random(max + 1)
|
||||||
|
}
|
||||||
|
state.estimatedHit = hit
|
||||||
|
|
||||||
|
victim.skills.updateLevel(Skills.DEFENCE, -hit, 0)
|
||||||
|
victim.skills.updateLevel(Skills.MAGIC, -hit, 0)
|
||||||
|
|
||||||
|
player.audioManager.send(AUTHENTIC_AUDIO)
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://oldschool.runescape.wiki/w/Dragon_axe
|
||||||
|
*/
|
||||||
|
private fun swingOSRS(entity: Entity?): Int {
|
||||||
|
val player = entity as? Player ?: return -1
|
||||||
|
if (!player.settings.drainSpecial(SPECIAL_ENERGY)) return -1
|
||||||
|
|
||||||
|
player.sendChat("Chop chop!")
|
||||||
|
player.skills.updateLevel(Skills.WOODCUTTING, 3, player.skills.getStaticLevel(Skills.WOODCUTTING) + 3)
|
||||||
|
visualize(player, null, null)
|
||||||
|
player.audioManager.send(OSRS_AUDIO)
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* The special energy required.
|
||||||
|
*/
|
||||||
|
private const val SPECIAL_ENERGY = 100
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attack animation.
|
||||||
|
*/
|
||||||
|
private val ANIMATION = Animation(2876, Priority.HIGH)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The graphic.
|
||||||
|
*/
|
||||||
|
private val GRAPHIC = Graphics(479, 96)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authentic sound.
|
||||||
|
*/
|
||||||
|
private val AUTHENTIC_AUDIO = Audio(2531)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The OSRS sound.
|
||||||
|
*/
|
||||||
|
private val OSRS_AUDIO = Audio(2530)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item.
|
||||||
|
*/
|
||||||
|
private val ITEM = Item(Items.DRAGON_AXE_6739)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -261,5 +261,8 @@ class ServerConstants {
|
|||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
var PERSIST_ACCOUNTS = false
|
var PERSIST_ACCOUNTS = false
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
var DRAGON_AXE_USE_OSRS_SPEC = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ object ServerConfigParser {
|
|||||||
ServerConstants.DAILY_ACCOUNT_LIMIT = data.getLong("server.daily_accounts_per_ip", 3L).toInt()
|
ServerConstants.DAILY_ACCOUNT_LIMIT = data.getLong("server.daily_accounts_per_ip", 3L).toInt()
|
||||||
ServerConstants.DISCORD_MOD_WEBHOOK = data.getString("server.moderation_webhook", "")
|
ServerConstants.DISCORD_MOD_WEBHOOK = data.getString("server.moderation_webhook", "")
|
||||||
ServerConstants.NOAUTH_DEFAULT_ADMIN = data.getBoolean("server.noauth_default_admin", false)
|
ServerConstants.NOAUTH_DEFAULT_ADMIN = data.getBoolean("server.noauth_default_admin", false)
|
||||||
|
ServerConstants.DRAGON_AXE_USE_OSRS_SPEC = data.getBoolean("world.dragon_axe_use_osrs_spec", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user