-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolo_ranger.15.js
139 lines (123 loc) · 3.57 KB
/
solo_ranger.15.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Load basic functions from other code snippet
load_code(7);
load_code(8);
// Kiting
var rangeRate = 0.7;
var rangerTarget = ["cgoo"];
var rangerMap = "level2s";
var rangerMapX = 9;
var rangerMapY = 432;
function getRangerTarget() {
if (rangerTarget && rangerTarget.length) {
for (const monsterName of rangerTarget) {
const monsterInstance = get_nearest_monster({ type: monsterName });
if (monsterInstance) return monsterInstance;
}
}
return undefined;
}
function fight(target) {
loot();
if (can_attack(target)) {
set_message("Attacking");
// Debuff
if (
!target.s.marked &&
character.mp > 300 &&
!is_on_cooldown("huntersmark") &&
target.hp > 3000
)
use_skill("huntersmark");
// Attacks
// if (character.mp > 400 && !is_on_cooldown("supershot"))
// use_skill("supershot", target);
const targetsToThreeshot = Object.keys(parent.entities)
.sort((lhs, rhs) => {
if (parent.entities[lhs].hp === parent.entities[rhs].hp)
return (
distance(character, parent.entities[rhs]) -
distance(character, parent.entities[lhs])
);
return parent.entities[lhs].hp - parent.entities[rhs].hp;
})
?.slice(0, 3)
.map((id) => parent.entities[id]);
if (
character.mp > 500 &&
!character.fear &&
targetsToThreeshot.filter((target) => is_in_range(target, "attack"))
.length >= 2 &&
!is_on_cooldown("3shot") &&
target.attack < 400 &&
character.hp > character.max_hp * 0.55
)
use_skill("3shot", targetsToThreeshot).then(() =>
reduce_cooldown("attack", character.ping * 0.95)
);
if (!is_on_cooldown("attack"))
attack(
Object.keys(parent.entities)
.sort((lhs, rhs) => {
if (parent.entities[lhs].hp === parent.entities[rhs].hp)
return (
distance(character, parent.entities[rhs]) -
distance(character, parent.entities[lhs])
);
return parent.entities[lhs].hp - parent.entities[rhs].hp;
})
.map((id) => parent.entities[id])?.[0]
).then(() => reduce_cooldown("attack", character.ping * 0.95));
}
if (!smartmoveDebug) {
hitAndRun(
Object.keys(parent.entities)
.filter(
(id) =>
parent.entities.type === "monster" &&
parent.entities[id].target === character.name
)
?.sort(
(lhs, rhs) =>
distance(character, parent.entities[lhs]) -
distance(character, parent.entities[rhs])
)[0] ?? target,
rangeRate
);
angle =
angle +
flipRotation *
Math.asin(
(character.speed * (1 / character.frequency)) /
8 /
(character.range * rangeRate)
) *
2;
} else {
angle = undefined;
}
}
setInterval(async function () {
loot();
buff();
if (character.rip) {
respawn();
return;
}
if (smart.moving && !smartmoveDebug) return;
let target = getRangerTarget() || getTarget();
//// BOSSES
if (goToBoss()) return;
//// EVENTS
target = (await changeToDailyEventTargets()) ?? getRangerTarget();
//// Logic to targets and farm places
if (!smart.moving && !target)
smart_move({
map: rangerMap || map,
x: rangerMapX || mapX,
y: rangerMapY || mapY,
}).catch((e) => use_skill("use_town"));
if (character.hp < 0.6 * character.max_hp && !get_entity(HEALER)) {
send_cm(HEALER, "party_heal");
}
fight(target);
}, ((1 / character.frequency) * 1000) / 4);