1package com.osroyale.content.activity.impl.duelarena;
3import com.osroyale.content.activity.ActivityListener;
4import com.osroyale.game.world.entity.combat.CombatType;
5import com.osroyale.game.world.entity.combat.hit.Hit;
6import com.osroyale.game.world.entity.mob.Mob;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.items.Item;
9import com.osroyale.net.packet.out.SendMessage;
13 DuelArenaListener(DuelArenaActivity
activity) {
18 public void start(Mob attacker, Mob defender, Hit[] hits) {
19 System.out.println(defender);
24 super.start(attacker, defender, hits);
28 public void onDamage(Mob defender, Hit hit) {
35 public void preKill(Mob attacker, Mob defender, Hit hit) {
36 activity.hasLoser =
true;
37 attacker.damageImmunity.reset();
41 public boolean canAttack(Mob attacker, Mob defender) {
45 if (player ==
null || opponent ==
null || !attacker.isPlayer() || !defender.isPlayer()) {
49 if (!attacker.equals(player) && !attacker.equals(opponent)) {
50 attacker.getPlayer().send(
new SendMessage(
"You are not in this duel."));
54 if (!defender.equals(player) && !defender.equals(opponent)) {
55 attacker.getPlayer().send(
new SendMessage(defender.getName() +
" is not your opponent!"));
60 attacker.getPlayer().send(
new SendMessage(
"The duel hasn't started yet!"));
64 if (
activity.rules.contains(DuelRule.ONLY_FUN_WEAPONS) && !DuelUtils.hasFunWeapon(attacker.getPlayer(), attacker.getPlayer().equipment.getWeapon())) {
65 attacker.getPlayer().send(
new SendMessage(
"You can only use fun weapons!"));
69 if (
activity.rules.contains(DuelRule.ONLY_WHIP_DDS)) {
70 if (attacker.getPlayer().equipment.hasWeapon()) {
71 Item weapon = attacker.getPlayer().equipment.getWeapon();
72 String name = weapon.getName().toLowerCase();
74 if (!name.contains(
"dragon dagger") && !name.contains(
"abyssal whip") && !name.contains(
"abyssal tentacle")) {
75 attacker.getPlayer().send(
new SendMessage(
"You can only use a whip or dragon dagger!"));
81 CombatType combatType = attacker.getPlayer().getStrategy().getCombatType();
83 if (combatType == CombatType.MELEE &&
activity.rules.contains(DuelRule.NO_MELEE)) {
84 attacker.getPlayer().send(
new SendMessage(
"You cannot use melee in the duel arena."));
88 if (combatType == CombatType.RANGED &&
activity.rules.contains(DuelRule.NO_RANGED)) {
89 attacker.getPlayer().send(
new SendMessage(
"You cannot use ranged in the duel arena."));
93 if (combatType == CombatType.MAGIC &&
activity.rules.contains(DuelRule.NO_MAGIC)) {
94 attacker.getPlayer().send(
new SendMessage(
"You cannot use magic in the duel arena."));
98 return super.canAttack(attacker, defender);