RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
RangedStrategy.java
1package com.osroyale.game.world.entity.combat.strategy.basic;
2
3import com.osroyale.content.activity.Activity;
4import com.osroyale.content.activity.impl.kraken.KrakenActivity;
5import com.osroyale.game.world.entity.combat.attack.FightType;
6import com.osroyale.game.world.entity.combat.hit.Hit;
7import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
8import com.osroyale.game.world.entity.mob.Mob;
9import com.osroyale.game.world.entity.mob.player.Player;
10import com.osroyale.game.world.entity.skill.Skill;
11import com.osroyale.game.world.pathfinding.path.SimplePathChecker;
12import com.osroyale.util.Utility;
13
17public abstract class RangedStrategy<T extends Mob> extends CombatStrategy<T> {
18
19 @Override
20 public boolean withinDistance(T attacker, Mob defender) {
21 if (attacker.isPlayer() && Activity.evaluate(attacker.getPlayer(), it -> it instanceof KrakenActivity)) {
22 return true;
23 }
24
25 FightType fightType = attacker.getCombat().getFightType();
26
27 int distance = getAttackDistance(attacker, fightType);
28
29 return Utility.inRange(attacker, defender, distance)
30 && (SimplePathChecker.checkProjectile(attacker, defender)
31 || SimplePathChecker.checkProjectile(defender, attacker));
32 }
33
34 protected static void addCombatExperience(Player player, Hit... hits) {
35 int exp = 0;
36 for (Hit hit : hits) {
37 if (hit.getDamage() <= 0) continue;
38 exp += hit.getDamage();
39 }
40
41 exp *= player.experienceRate;
42 if (player.getCombat().getFightType() == FightType.FLARE) {
43 exp *= 4;
44 player.skills.addExperience(Skill.HITPOINTS, exp / 3);
45 player.skills.addExperience(Skill.RANGED, exp);
46 } else if (player.getCombat().getFightType() == FightType.SCORCH) {
47 exp *= 4;
48 player.skills.addExperience(Skill.HITPOINTS, exp / 3);
49 player.skills.addExperience(Skill.STRENGTH, exp);
50 } else if (player.getCombat().getFightType() == FightType.BLAZE) {
51 exp *= 2;
52 player.skills.addExperience(Skill.HITPOINTS, exp / 3);
53 player.skills.addExperience(Skill.MAGIC, exp);
54 } else {
55 player.skills.addExperience(Skill.HITPOINTS, exp / 3);
56
57 switch (player.getCombat().getFightType().getStyle()) {
58 case DEFENSIVE:
59 exp /= 2;
60 player.skills.addExperience(Skill.RANGED, exp);
61 player.skills.addExperience(Skill.DEFENCE, exp);
62 break;
63 default:
64 player.skills.addExperience(Skill.RANGED, exp);
65 break;
66 }
67 }
68 }
69
70}