vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Combat Caller |
||
3 | By Alex Brazie |
||
4 | |||
5 | Automates Low-HP and Out-Of-Mana calls |
||
6 | |||
7 | This was written for testing of the shared |
||
8 | configuration module I'm writing. |
||
9 | (But first, I need a module to configure!) |
||
10 | |||
11 | ]]-- |
||
12 | |||
13 | -- Modded by Arys 02-02-05 |
||
14 | -- Changed limit sliders to move at 5% increments and range from 10%-90% |
||
15 | -- Force a minimum cooldown of 1 second even when disabled |
||
16 | |||
17 | -- These will be the values with checkboxes |
||
18 | CombatCaller_HealthCall = true; |
||
19 | CombatCaller_ManaCall = true; |
||
20 | CombatCaller_Cooldown = true; |
||
21 | |||
22 | -- These will be the variable variables. ;) |
||
23 | CombatCaller_HealthRatio = .4; |
||
24 | CombatCaller_HealthLimit = 100; |
||
25 | CombatCaller_ManaRatio = .3; |
||
26 | CombatCaller_ManaLimit = 150; |
||
27 | CombatCaller_CooldownTime = 30; |
||
28 | |||
29 | function CombatCaller_OnLoad() |
||
30 | this:RegisterEvent("UNIT_HEALTH"); |
||
31 | this:RegisterEvent("UNIT_MANA"); |
||
32 | this:RegisterEvent("PLAYER_ENTER_COMBAT"); |
||
33 | this:RegisterEvent("PLAYER_LEAVE_COMBAT"); |
||
34 | |||
35 | this.hp = -1; |
||
36 | this.mana = -1; |
||
37 | this.lasthp = -1; |
||
38 | this.lastmana = -1; |
||
39 | this.InCombat = 0; |
||
40 | this.IsGhost = 0; |
||
41 | this.LastHPShout = 0; |
||
42 | this.LastManaShout = 0; |
||
43 | |||
44 | if ( UltimateUI_RegisterConfiguration ) then |
||
45 | -- Register with the UltimateUIMaster |
||
46 | UltimateUI_RegisterConfiguration( |
||
47 | "UUI_COMCALLER", |
||
48 | "SECTION", |
||
49 | COMBATC_SEP, |
||
50 | COMBATC_SEP_INFO |
||
51 | ); |
||
52 | UltimateUI_RegisterConfiguration( |
||
53 | "UUI_COMCALLER_HEADER", |
||
54 | "SEPARATOR", |
||
55 | COMBATC_SEP, |
||
56 | COMBATC_SEP_INFO |
||
57 | ); |
||
58 | UltimateUI_RegisterConfiguration( |
||
59 | "UUI_COMCALLER_HEALTHSLIMIT", --CVar |
||
60 | "BOTH", --Things to use |
||
61 | COMBATC_HEALTH, --Simple String |
||
62 | COMBATC_HEALTH_INFO, |
||
63 | --Description |
||
64 | CombatCaller_OnHealthConfigUpdate, --Callback |
||
65 | 0, --Default Checked/Unchecked |
||
66 | .2, --Default Value |
||
67 | .1, --Min value |
||
68 | .9, --Max value |
||
69 | COMBATC_HEALTH_LIMIT, --Slider Text |
||
70 | .05, --Slider Increment |
||
71 | 1, --Slider state text on/off |
||
72 | "\%", --Slider state text append |
||
73 | 100 --Slider state text multiplier |
||
74 | ); |
||
75 | UltimateUI_RegisterConfiguration( |
||
76 | "UUI_COMCALLER_MANASLIMIT", |
||
77 | "BOTH", |
||
78 | COMBATC_MANA, |
||
79 | COMBATC_MANA_INFO, |
||
80 | --Description |
||
81 | CombatCaller_OnManaConfigUpdate, |
||
82 | 0, |
||
83 | .2, |
||
84 | .1, |
||
85 | .9, |
||
86 | COMBATC_MANA_LIMIT, |
||
87 | .05, |
||
88 | 1, |
||
89 | "\%", |
||
90 | 100 |
||
91 | ); |
||
92 | UltimateUI_RegisterConfiguration( |
||
93 | "UUI_COMCALLER_COOLDOWN", |
||
94 | "SLIDER", |
||
95 | COMBATC_COOL, |
||
96 | COMBATC_COOL_INFO, |
||
97 | --Description |
||
98 | CombatCaller_OnCooldownUpdate, |
||
99 | 1, |
||
100 | 30, |
||
101 | 1, |
||
102 | 60, |
||
103 | COMBATC_COOL_LIMIT, |
||
104 | 1, |
||
105 | 1, |
||
106 | COMBATC_COOL_SEC, |
||
107 | 1 |
||
108 | ); |
||
109 | end |
||
110 | end |
||
111 | |||
112 | function CombatCaller_OnEvent(event) |
||
113 | if ( UnitIsDeadOrGhost("player") ) then |
||
114 | this.IsGhost = 1; |
||
115 | return; |
||
116 | elseif ( this.IsGhost == 1 ) then |
||
117 | this.hp = UnitHealth("player"); |
||
118 | this.lasthp = this.hp; |
||
119 | this.mana = UnitMana("player"); |
||
120 | this.lastmana = this.mana; |
||
121 | this.IsGhost = 0; |
||
122 | this.InCombat = 0; |
||
123 | return; |
||
124 | end |
||
125 | if (event == "PLAYER_ENTER_COMBAT") then |
||
126 | this.InCombat = 1; |
||
127 | elseif (event == "PLAYER_LEAVE_COMBAT") then |
||
128 | this.InCombat = 0; |
||
129 | end |
||
130 | if( this.InCombat == 0 ) then |
||
131 | return; |
||
132 | end |
||
133 | if ( event == "UNIT_HEALTH" ) then |
||
134 | local ratio = UnitHealth("player")/UnitHealthMax("player"); |
||
135 | local oldratio = this.lasthp/UnitHealthMax("player"); |
||
136 | |||
137 | |||
138 | if ( (this.hp < this.lasthp) and |
||
139 | (ratio < CombatCaller_HealthRatio) and |
||
140 | (GetTime() - this.LastHPShout > CombatCaller_CooldownTime) and |
||
141 | (oldratio > CombatCaller_HealthRatio)) then |
||
142 | CombatCaller_ShoutLowHealth(); |
||
143 | this.LastHPShout = GetTime(); |
||
144 | end |
||
145 | |||
146 | this.lasthp = this.hp; |
||
147 | this.hp = UnitHealth("player"); |
||
148 | end |
||
149 | if ( event == "UNIT_MANA" ) then |
||
150 | if(UnitPowerType("player") ~= 0) then |
||
151 | this.lastmana = 0; |
||
152 | else |
||
153 | local ratio = UnitMana("player")/UnitManaMax("player"); |
||
154 | local oldratio = this.lastmana/UnitManaMax("player"); |
||
155 | |||
156 | if ( (this.mana < this.lastmana) and |
||
157 | (ratio < CombatCaller_ManaRatio) and |
||
158 | (GetTime() - this.LastManaShout > CombatCaller_CooldownTime) and |
||
159 | (oldratio > CombatCaller_ManaRatio) ) then |
||
160 | CombatCaller_ShoutLowMana(); |
||
161 | this.LastManaShout = GetTime(); |
||
162 | end |
||
163 | |||
164 | this.lastmana = this.mana; |
||
165 | this.mana = UnitMana("player"); |
||
166 | end |
||
167 | end |
||
168 | end |
||
169 | |||
170 | function CombatCaller_OnHealthConfigUpdate(toggle, value) |
||
171 | if ( toggle == 0 ) then |
||
172 | CombatCaller_HealthCall = false; |
||
173 | else |
||
174 | CombatCaller_HealthCall = true; |
||
175 | CombatCaller_HealthRatio = value; |
||
176 | end |
||
177 | end |
||
178 | |||
179 | function CombatCaller_OnManaConfigUpdate(toggle, value) |
||
180 | if ( toggle == 0 ) then |
||
181 | CombatCaller_ManaCall = false; |
||
182 | else |
||
183 | CombatCaller_ManaCall = true; |
||
184 | CombatCaller_ManaRatio = value; |
||
185 | end |
||
186 | end |
||
187 | function CombatCaller_OnCooldownUpdate(toggle, value) |
||
188 | CombatCaller_Cooldown = true; |
||
189 | CombatCaller_CooldownTime = value; |
||
190 | end |
||
191 | |||
192 | function CombatCaller_ShoutLowHealth() |
||
193 | if ( CombatCaller_HealthCall and this.InCombat == 1 ) then |
||
194 | DoEmote("HEALME"); |
||
195 | end |
||
196 | end |
||
197 | |||
198 | function CombatCaller_ShoutLowMana() |
||
199 | if ( CombatCaller_ManaCall and this.InCombat == 1 ) then |
||
200 | DoEmote("OUTOFMANA"); |
||
201 | end |
||
202 | end |
||
203 | |||
204 | function CombatCaller_TurnOff() |
||
205 | CombatCaller_HealthCall = false; |
||
206 | CombatCaller_ManaCall = false; |
||
207 | end |
||
208 | |||
209 | function CombatCaller_TurnOn() |
||
210 | CombatCaller_HealthCall = true; |
||
211 | CombatCaller_ManaCall = true; |
||
212 | end |
||
213 | |||
214 |