vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | local mod = klhtm |
||
3 | local me = {} |
||
4 | mod.alert = me |
||
5 | |||
6 | ---------------------- |
||
7 | -- Aggro loss / gain notification |
||
8 | |||
9 | -- This stuff is just debug material, to print out your threat when you gain or lose aggro. |
||
10 | ---------------------- |
||
11 | |||
12 | me.notifyaggro = false |
||
13 | me.targetname = "nil" |
||
14 | me.targettargetname = "nil" |
||
15 | |||
16 | function klhtest() |
||
17 | |||
18 | me.notifyaggro = not me.notifyaggro |
||
19 | |||
20 | if me.notifyaggro == true then |
||
21 | mod.out.print("Now notifying you of aggro changes.") |
||
22 | else |
||
23 | mod.out.print("No longer notifying you of aggro changes.") |
||
24 | end |
||
25 | |||
26 | end |
||
27 | |||
28 | me.onupdate = function() |
||
29 | |||
30 | if me.notifyaggro == false then |
||
31 | return |
||
32 | end |
||
33 | |||
34 | -- get current ID's. If you are targetting friend, then use HIS targets |
||
35 | local targetid = "target" |
||
36 | local doubletargetid = "targettarget" |
||
37 | |||
38 | if UnitIsFriend("player", "target") then |
||
39 | targetid = targetid .. "target" |
||
40 | doubletargetid = doubletargetid .. "target" |
||
41 | end |
||
42 | |||
43 | -- check for valid targets |
||
44 | if UnitIsFriend("player", targetid) then |
||
45 | -- there are no enemies around. don't do anything |
||
46 | me.targetname = "nil" |
||
47 | return |
||
48 | end |
||
49 | |||
50 | -- now see if the target has changed |
||
51 | local targetnow = UnitName(targetid) |
||
52 | |||
53 | if targetnow == nil or targetnow == "Unknown Entity" then |
||
54 | -- no mob targetted. ignore |
||
55 | targetnow = "nil" |
||
56 | return |
||
57 | end |
||
58 | |||
59 | -- get target target name |
||
60 | local doubletargetnow = UnitName(doubletargetid) |
||
61 | if doubletargetnow == nil then |
||
62 | doubletargetnow = "nil" |
||
63 | end |
||
64 | |||
65 | -- check for target change |
||
66 | if targetnow ~= me.targetname then |
||
67 | |||
68 | -- target change. ignore targettarget therefore |
||
69 | me.targetname = targetnow |
||
70 | me.targettargetname = doubletargetnow |
||
71 | return |
||
72 | end |
||
73 | |||
74 | -- to get here, target is valid and is the same. we want to see if targettarget is changed |
||
75 | |||
76 | -- is change? |
||
77 | if doubletargetnow ~= me.targettargetname then |
||
78 | |||
79 | -- changed to nil |
||
80 | if doubletargetnow == "nil" then |
||
81 | if UnitIsDead(targetid) then |
||
82 | -- target lost its target, because it died. |
||
83 | me.targetname = "nil" |
||
84 | |||
85 | else |
||
86 | -- target temporarily lost its target. probably it is stunned |
||
87 | -- so just don't update targettarget to nil |
||
88 | end |
||
89 | |||
90 | return |
||
91 | end |
||
92 | |||
93 | if me.targettargetname == "nil" then |
||
94 | -- picked it up from noone. no announce. |
||
95 | |||
96 | elseif me.targettargetname == UnitName("Player") then |
||
97 | -- we lost aggro |
||
98 | -- mod.out.announce("I lost aggro to " .. doubletargetnow .. ". His threat should be at least " .. math.ceil(KLHTM_MyData["Total"].threat * 1.1) .. ". " .. me.enumeratethreat()) |
||
99 | |||
100 | elseif doubletargetnow == UnitName("Player") then |
||
101 | -- we gained aggro |
||
102 | mod.out.announce("I gained aggro from " .. me.targettargetname .. ". My threat is " .. math.ceil(mod.table.mydata["Total"].threat) .. ". " .. me.enumeratethreat(true)) |
||
103 | end |
||
104 | |||
105 | me.targettargetname = doubletargetnow |
||
106 | end |
||
107 | |||
108 | end |
||
109 | |||
110 | me.enumeratethreat = function(lastmessage) |
||
111 | |||
112 | local message = "Damage = " .. mod.table.mydata["Total"].damage |
||
113 | |||
114 | local key; local value |
||
115 | |||
116 | for key, value in mod.table.mydata do |
||
117 | if key == "Healing" then |
||
118 | message = message .. ", Healing = " .. value.damage |
||
119 | |||
120 | elseif key ~= "Total" and key ~= "White Damage" then |
||
121 | if value.hits > 0 then |
||
122 | message = message .. ", " .. key .. " " .. value.hits .. " hits" |
||
123 | end |
||
124 | end |
||
125 | end |
||
126 | |||
127 | if lastmessage then |
||
128 | |||
129 | local threat = mod.table.mydata["Total"].threat |
||
130 | message = message .. ". Threat = " .. threat |
||
131 | |||
132 | if mod.combat.lastattack then |
||
133 | threat = threat - mod.combat.lastattack.threat |
||
134 | message = message .. ", then " .. threat |
||
135 | end |
||
136 | |||
137 | if mod.combat.lastattack then |
||
138 | threat = threat - mod.combat.lastattack.threat |
||
139 | message = message .. ", then " .. threat |
||
140 | end |
||
141 | end |
||
142 | |||
143 | message = message .. "." |
||
144 | |||
145 | return message |
||
146 | |||
147 | end |