RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ZulrahHelm.java
1package com.osroyale.game.world.entity.combat.attack.listener.item;
2
3import com.osroyale.game.world.entity.combat.attack.listener.ItemCombatListenerSignature;
4import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
5import com.osroyale.game.world.entity.combat.effect.impl.CombatPoisonEffect;
6import com.osroyale.game.world.entity.combat.effect.impl.CombatVenomEffect;
7import com.osroyale.game.world.entity.combat.hit.Hit;
8import com.osroyale.game.world.entity.mob.Mob;
9import com.osroyale.game.world.entity.mob.player.Player;
10import com.osroyale.game.world.items.Item;
11import com.osroyale.game.world.items.containers.equipment.Equipment;
12import com.osroyale.util.RandomUtils;
13
14@ItemCombatListenerSignature(requireAll = false, items = { 12_931, 13_197, 13_199 })
15public class ZulrahHelm extends SimplifiedListener<Player> {
16
17 @Override
18 public void hit(Player attacker, Mob defender, Hit hit) {
19 if (!defender.isNpc()) {
20 return;
21 }
22
23 Item helm = attacker.equipment.get(Equipment.HELM_SLOT);
24
25 if (helm == null) {
26 return;
27 }
28
29 if (helm.matchesId(12_931)) {
30 serp(attacker, defender, this);
31 } else if (helm.matchesId(13_197)) {
32 tanz(attacker, defender, this);
33 } else if (helm.matchesId(13_199)) {
34 magma(attacker, defender, this);
35 }
36 }
37
38 private static void serp(Player attacker, Mob defender, ZulrahHelm listener) {
39 if (attacker.serpentineHelmCharges > 0) {
40 attacker.serpentineHelmCharges -= 2;
41 boolean poisonous = false;
42
43 if (attacker.equipment.hasWeapon()) {
44 poisonous = CombatPoisonEffect.getPoisonType(attacker.equipment.getWeapon()).isPresent();
45 }
46
47 if (!poisonous && attacker.equipment.hasAmmo()) {
48 poisonous = CombatPoisonEffect.getPoisonType(attacker.equipment.get(Equipment.ARROWS_SLOT)).isPresent();
49 }
50
51 if (CombatVenomEffect.isVenomous(attacker.equipment.getWeapon())) {
52 defender.venom();
53 } else if (RandomUtils.success(poisonous ? 0.50 : 1 / 6.0)) {
54 defender.venom();
55 }
56 }
57
58 if (attacker.serpentineHelmCharges == 0) {
59 attacker.message("Your Serpentine helm is out of charges.");
60 attacker.equipment.set(Equipment.HELM_SLOT, new Item(12_929), true);
61 attacker.getCombat().removeListener(listener);
62 }
63 }
64
65 private static void tanz(Player attacker, Mob defender, ZulrahHelm listener) {
66 if (attacker.tanzaniteHelmCharges > 0) {
67 attacker.tanzaniteHelmCharges -= 2;
68 boolean poisonous = false;
69
70 if (attacker.equipment.hasWeapon()) {
71 poisonous = CombatPoisonEffect.getPoisonType(attacker.equipment.getWeapon()).isPresent();
72 }
73
74 if (!poisonous && attacker.equipment.hasAmmo()) {
75 poisonous = CombatPoisonEffect.getPoisonType(attacker.equipment.get(Equipment.ARROWS_SLOT)).isPresent();
76 }
77
78 if (CombatVenomEffect.isVenomous(attacker.equipment.getWeapon())) {
79 defender.venom();
80 } else if (RandomUtils.success(poisonous ? 0.50 : 1 / 6.0)) {
81 defender.venom();
82 }
83 }
84
85 if (attacker.tanzaniteHelmCharges == 0) {
86 attacker.message("Your Tanzanite helm is out of charges.");
87 attacker.equipment.set(Equipment.HELM_SLOT, new Item(13_196), true);
88 attacker.getCombat().removeListener(listener);
89 }
90 }
91
92 private static void magma(Player attacker, Mob defender, ZulrahHelm listener) {
93 if (attacker.magmaHelmCharges > 0) {
94 attacker.magmaHelmCharges -= 2;
95 boolean poisonous = false;
96
97 if (attacker.equipment.hasWeapon()) {
98 poisonous = CombatPoisonEffect.getPoisonType(attacker.equipment.getWeapon()).isPresent();
99 }
100
101 if (!poisonous && attacker.equipment.hasAmmo()) {
102 poisonous = CombatPoisonEffect.getPoisonType(attacker.equipment.get(Equipment.ARROWS_SLOT)).isPresent();
103 }
104
105 if (CombatVenomEffect.isVenomous(attacker.equipment.getWeapon())) {
106 defender.venom();
107 } else if (RandomUtils.success(poisonous ? 0.50 : 1 / 6.0)) {
108 defender.venom();
109 }
110 }
111
112 if (attacker.magmaHelmCharges == 0) {
113 attacker.message("Your Magma helm is out of charges.");
114 attacker.equipment.set(Equipment.HELM_SLOT, new Item(13_198), true);
115 attacker.getCombat().removeListener(listener);
116 }
117 }
118
119
120}