forked from StrawberryPear/healstatus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGestureHandler.lua
107 lines (87 loc) · 3.06 KB
/
GestureHandler.lua
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
local _, addon = ...;
local MOUNT_NAMES = {
"Steed", "Charger", "Battle Tank", "Felsteed", "Mare"
};
local FORCE_FOLLOW_SCORE = 9999;
local DEFAULT_MOUNT_SCORE = 35;
local DEFAULT_PRIO_FOLLOW_SCORE = 35;
local DEFAULT_FOLLOW_SCORE = 15;
local DEFAULT_MOVING_THRESHOLD = 8; -- within 8 seconds, we can start jumpin'.
local SPEED_THRESHOLD = 7;
addon.getShouldMount = function()
local isMounted = addon.getTargetHasBuff(addon.followBean.target, MOUNT_NAMES);
local isPlayerMounted = addon.getTargetHasBuff("player", MOUNT_NAMES);
if (isMounted ~= isPlayerMounted) then
if (addon.playerBean["isInCombat"] and isMounted) then
return false
else
return true;
end
end
return false;
end
addon.updateFollow = function()
if (addon.playerBean["isMoving"]) then
addon.followBean.playerLastMoving = GetTime();
end
-- logic. never let the target player go outside of follow range
if (UnitIsDeadOrGhost(addon.followBean.target)) then
return;
end
addon.followBean.followAction = "Nothing";
addon.followBean.followScore = 0;
addon.followBean.followTarget = -1;
if LightStatus.followBlock then
return
end
if (addon.followBean.targetName) then
local inTen = CheckInteractDistance(addon.followBean.target, 2); -- 10 yard range
local inTwenty = IsItemInRange(6450, addon.followBean.target);
local inThirty = CheckInteractDistance(addon.followBean.target, 4); -- 30 yard range
local inFourty = UnitInRange(addon.followBean.target);
if (inFourty and addon.getShouldMount()) then
addon.followBean.followAction = "Mount";
addon.followBean.followScore = DEFAULT_MOUNT_SCORE;
addon.followBean.followTarget = -1;
if (LightStatus.onlyFollow) then
addon.followBean.followScore = FORCE_FOLLOW_SCORE;
end
return;
end
if (not inThirty) then
addon.followBean.followScore = 0;
-- find a new follow target
for k, v in pairs(addon.friendBean) do
if (v ~= nil) then
if ((not (k == addon.playerGuid)) and v.isInFollowRange) then
addon.followBean.followTarget = v.targetString;
addon.followBean.followAction = "Follow";
addon.followBean.followScore = DEFAULT_PRIO_FOLLOW_SCORE;
if (LightStatus.onlyFollow) then
addon.followBean.followScore = FORCE_FOLLOW_SCORE;
end
break;
end
end
end
else
addon.followBean.followTarget = addon.followBean.target;
addon.followBean.followAction = "Follow";
addon.followBean.followScore = 0;
if ((not addon.playerBean["isInCombat"]) or (GetUnitSpeed(addon.followBean.target) ~= 0)) then
if (LightStatus.onlyFollow) then
addon.followBean.followScore = FORCE_FOLLOW_SCORE;
elseif (inThirty and not inTwenty) then
addon.followBean.followScore = DEFAULT_PRIO_FOLLOW_SCORE;
elseif (inTwenty and not inTen) then
addon.followBean.followScore = DEFAULT_FOLLOW_SCORE;
end
end
if ((addon.followBean.followScore > 0) and
(addon.playerBean["speed"] > 0)) then
-- assume player is moving
addon.followBean.followAction = "Jump";
end
end
end
end