forked from quisquous/cactbot
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathdps_common.js
72 lines (61 loc) · 1.9 KB
/
dps_common.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
import { addOverlayListener } from '../../resources/overlay_plugin_api';
import ContentType from '../../resources/content_type';
import Util from '../../resources/util';
import ZoneInfo from '../../resources/zone_info';
export const defaultOptions = {
Language: 'en',
IgnoreContentTypes: [
ContentType.Pvp,
ContentType.Eureka,
ContentType.SaveTheQueen,
],
};
let gIgnoreCurrentZone = false;
let gIgnoreCurrentJob = false;
let gCurrentJob = null;
let gCurrentZone = null;
let gInCombat = false;
export const InitDpsModule = function(options, updateFunc, hideFunc) {
addOverlayListener('CombatData', (e) => {
// DPS numbers in large pvp is not useful and hella noisy.
if (gIgnoreCurrentZone || gIgnoreCurrentJob)
return;
// When ACT stops, stop updating. This is mostly to avoid
// a spurious update when changing zones which will unhide
// the dps overlay.
if (!gInCombat)
return;
// Don't bother showing the first "Infinity" dps right as
// combat starts.
const dps = parseFloat(e.Encounter.encdps);
if (dps <= 0 || dps === Infinity)
return;
updateFunc({ detail: e });
});
addOverlayListener('ChangeZone', (e) => {
const newZone = e.zoneName;
if (gCurrentZone === newZone)
return;
// Always hide on switching zones.
hideFunc();
gCurrentZone = newZone;
const zoneInfo = ZoneInfo[e.zoneID];
const contentType = zoneInfo ? zoneInfo.contentType : 0;
gIgnoreCurrentZone = options.IgnoreContentTypes.includes(contentType);
});
addOverlayListener('onInCombatChangedEvent', (e) => {
gInCombat = e.detail.inACTCombat;
});
addOverlayListener('onPlayerChangedEvent', (e) => {
const job = e.detail.job;
if (job === gCurrentJob)
return;
gCurrentJob = job;
if (Util.isCombatJob(job)) {
gIgnoreCurrentJob = false;
return;
}
gIgnoreCurrentJob = true;
hideFunc();
});
};