Repository navigation
Expand file tree
/
Copy pathWCS_BrainMajorDemons.lua
More file actions
489 lines (414 loc) · 16 KB
/
Copy pathWCS_BrainMajorDemons.lua
File metadata and controls
489 lines (414 loc) · 16 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
if WCS_Brain and WCS_Brain.ENABLED == false then return end
--[[
WCS_BrainMajorDemons.lua v6.5.0
Sistema de Deteccion y Manejo de Demonios Mayores (Infernal y Doomguard)
Compatible con Lua 5.0 (Turtle WoW / WoW 1.12)
Este modulo extiende WCS_BrainPetAI con soporte mejorado para:
- Infernal: Invocado con Inferno, dura 5 minutos
- Doomguard: Invocado con Ritual of Doom
v6.5.0: Alertas visuales mejoradas (60s, 30s, 15s)
]]
WCS_BrainMajorDemons = WCS_BrainMajorDemons or {}
local MajorDemons = WCS_BrainMajorDemons
MajorDemons.VERSION = "6.5.0"
MajorDemons.debug = false
-- Estado de tracking
MajorDemons.State = {
currentDemon = nil,
summonTime = nil,
warning60Shown = false,
warning30Shown = false,
warning15Shown = false,
lastPetName = nil
}
-- Duraciones conocidas (en segundos)
MajorDemons.DURATIONS = {
Infernal = 300,
Doomguard = 300
}
-- ============================================================================
-- FUNCIONES DE UTILIDAD (Lua 5.0 compatible)
-- ============================================================================
function MajorDemons:Print(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cffff6600[MajorDemons]|r " .. tostring(msg))
end
function MajorDemons:DebugPrint(msg)
if self.debug then
DEFAULT_CHAT_FRAME:AddMessage("|cffff6600[MajorDemons Debug]|r " .. tostring(msg))
end
end
local function GetTime_Safe()
if GetTime then
return GetTime()
end
return 0
end
-- ============================================================================
-- DETECCION AVANZADA DE DEMONIOS MAYORES
-- ============================================================================
function MajorDemons:DetectMajorDemon()
if not UnitExists("pet") then
return nil
end
local petName = UnitName("pet")
if not petName then
return nil
end
petName = string.lower(petName)
-- ========================================================================
-- DETECCION POR NOMBRE
-- ========================================================================
-- Infernal (EN: Infernal, ES: Infernal)
if string.find(petName, "infernal") then
return "Infernal"
end
if string.find(petName, "inferno") then
return "Infernal"
end
-- Doomguard (EN: Doomguard, ES: Guardia apocaliptico)
if string.find(petName, "doomguard") then
return "Doomguard"
end
if string.find(petName, "doom") then
return "Doomguard"
end
if string.find(petName, "apocal") then
return "Doomguard"
end
if string.find(petName, "destino") then
return "Doomguard"
end
-- Caso especial: "guardia" sin "fel" = Doomguard
if string.find(petName, "guardia") then
if not string.find(petName, "fel") then
if not string.find(petName, "vil") then
return "Doomguard"
end
end
end
-- ========================================================================
-- DETECCION POR HABILIDADES EN BARRA DE MASCOTA
-- ========================================================================
local i = 1
while i <= 10 do
local name = GetPetActionInfo(i)
if name then
name = string.lower(name)
-- Infernal: Immolation Aura
if string.find(name, "immolation") then
return "Infernal"
end
if string.find(name, "inmolacion") then
return "Infernal"
end
-- Doomguard: War Stomp, Cripple, Rain of Fire
if string.find(name, "war stomp") then
return "Doomguard"
end
if string.find(name, "cripple") then
return "Doomguard"
end
if string.find(name, "rain of fire") then
return "Doomguard"
end
if string.find(name, "pisoteon") then
return "Doomguard"
end
if string.find(name, "tullir") then
return "Doomguard"
end
if string.find(name, "lluvia") then
return "Doomguard"
end
end
i = i + 1
end
-- ========================================================================
-- DETECCION POR CARACTERISTICAS (fallback)
-- ========================================================================
local petMana = UnitManaMax("pet")
if not petMana then
petMana = 0
end
-- Los demonios mayores no tienen mana
if petMana == 0 then
local petHP = UnitHealthMax("pet")
if petHP and petHP > 0 then
self:DebugPrint("Pet sin mana detectado - posible demonio mayor")
-- Verificar que no sea un demonio normal
-- Los demonios normales siempre tienen mana
return "Infernal"
end
end
return nil
end
-- ============================================================================
-- TRACKING DE TIEMPO
-- ============================================================================
function MajorDemons:OnDemonSummoned(demonType)
self.State.currentDemon = demonType
self.State.summonTime = GetTime_Safe()
self.State.warning60Shown = false
self.State.warning30Shown = false
self.State.warning15Shown = false
self.State.lastPetName = UnitName("pet")
self:Print("|cff00ff00" .. demonType .. " INVOCADO!|r")
local duration = self.DURATIONS[demonType]
if not duration then
duration = 300
end
self:Print(" Duracion estimada: " .. duration .. " segundos")
-- Notificar a PetAI si existe
if WCS_BrainPetAI then
WCS_BrainPetAI.majorDemonSummonTime = self.State.summonTime
WCS_BrainPetAI.majorDemonType = demonType
end
end
function MajorDemons:GetTimeRemaining()
if not self.State.summonTime then
return 0
end
if not self.State.currentDemon then
return 0
end
local elapsed = GetTime_Safe() - self.State.summonTime
local duration = self.DURATIONS[self.State.currentDemon]
if not duration then
duration = 300
end
local remaining = duration - elapsed
if remaining < 0 then
remaining = 0
end
return remaining
end
function MajorDemons:ResetState()
if self.State.currentDemon then
self:DebugPrint("Demonio mayor perdido: " .. self.State.currentDemon)
end
self.State.currentDemon = nil
self.State.summonTime = nil
self.State.warning60Shown = false
self.State.warning30Shown = false
self.State.warning15Shown = false
self.State.lastPetName = nil
-- Limpiar en PetAI
if WCS_BrainPetAI then
WCS_BrainPetAI.majorDemonSummonTime = nil
WCS_BrainPetAI.majorDemonType = nil
end
end
-- ============================================================================
-- EVALUACION DE INFERNAL
-- ============================================================================
function MajorDemons:EvaluateInfernal()
local timeRemaining = self:GetTimeRemaining()
-- Alertas múltiples con sistema visual
if timeRemaining > 0 then
-- Alerta 60 segundos
if timeRemaining <= 60 and timeRemaining > 59 and not self.State.warning60Shown then
self.State.warning60Shown = true
if WCS_BrainMajorDemonAlerts then
WCS_BrainMajorDemonAlerts:ShowAlert("Infernal", 60, "normal")
else
self:Print("|cffFFFF00AVISO:|r Infernal expira en 60 segundos!")
end
end
-- Alerta 30 segundos
if timeRemaining <= 30 and timeRemaining > 29 and not self.State.warning30Shown then
self.State.warning30Shown = true
if WCS_BrainMajorDemonAlerts then
WCS_BrainMajorDemonAlerts:ShowAlert("Infernal", 30, "high")
else
self:Print("|cffFF8800AVISO:|r Infernal expira en 30 segundos!")
end
end
-- Alerta 15 segundos (CRÍTICA)
if timeRemaining <= 15 and timeRemaining > 14 and not self.State.warning15Shown then
self.State.warning15Shown = true
if WCS_BrainMajorDemonAlerts then
WCS_BrainMajorDemonAlerts:ShowAlert("Infernal", 15, "critical")
else
self:Print("|cffFF0000ALERTA CRÍTICA:|r Infernal expira en 15 segundos!")
end
end
end
-- Debug
if self.debug then
if timeRemaining > 0 then
self:DebugPrint("Infernal - Tiempo restante: " .. string.format("%.0f", timeRemaining) .. "s")
end
end
return false
end
-- ============================================================================
-- EVALUACION DE DOOMGUARD
-- ============================================================================
function MajorDemons:EvaluateDoomguard()
local timeRemaining = self:GetTimeRemaining()
-- Alertas múltiples con sistema visual
if timeRemaining > 0 then
-- Alerta 60 segundos
if timeRemaining <= 60 and timeRemaining > 59 and not self.State.warning60Shown then
self.State.warning60Shown = true
if WCS_BrainMajorDemonAlerts then
WCS_BrainMajorDemonAlerts:ShowAlert("Doomguard", 60, "normal")
else
self:Print("|cffFFFF00AVISO:|r Doomguard expira en 60 segundos!")
end
end
-- Alerta 30 segundos
if timeRemaining <= 30 and timeRemaining > 29 and not self.State.warning30Shown then
self.State.warning30Shown = true
if WCS_BrainMajorDemonAlerts then
WCS_BrainMajorDemonAlerts:ShowAlert("Doomguard", 30, "high")
else
self:Print("|cffFF8800AVISO:|r Doomguard expira en 30 segundos!")
end
end
-- Alerta 15 segundos (CRÍTICA)
if timeRemaining <= 15 and timeRemaining > 14 and not self.State.warning15Shown then
self.State.warning15Shown = true
if WCS_BrainMajorDemonAlerts then
WCS_BrainMajorDemonAlerts:ShowAlert("Doomguard", 15, "critical")
else
self:Print("|cffFF0000ALERTA CRÍTICA:|r Doomguard expira en 15 segundos!")
end
end
end
-- Debug
if self.debug then
if timeRemaining > 0 then
self:DebugPrint("Doomguard - Tiempo restante: " .. string.format("%.0f", timeRemaining) .. "s")
end
end
return false
end
-- ============================================================================
-- UPDATE PRINCIPAL
-- ============================================================================
function MajorDemons:Update()
local detectedDemon = self:DetectMajorDemon()
-- Nuevo demonio mayor detectado
if detectedDemon then
if detectedDemon ~= self.State.currentDemon then
self:OnDemonSummoned(detectedDemon)
end
end
-- Demonio mayor perdido (pet murio o expiro)
if not detectedDemon then
if self.State.currentDemon then
self:ResetState()
end
end
-- Evaluar demonio actual
if self.State.currentDemon == "Infernal" then
self:EvaluateInfernal()
elseif self.State.currentDemon == "Doomguard" then
self:EvaluateDoomguard()
end
end
-- ============================================================================
-- FUNCIONES PUBLICAS PARA INTEGRACION
-- ============================================================================
-- ============================================================================
-- METODOS DE INTEGRACION (encapsulados)
-- ============================================================================
function WCS_BrainMajorDemons:IsMajorDemon()
if self.State.currentDemon then
return true
end
return false
end
function WCS_BrainMajorDemons:GetDemonTypePublic()
return self.State.currentDemon
end
function WCS_BrainMajorDemons:GetTimeRemainingPublic()
return self:GetTimeRemaining()
end
-- ============================================================================
-- ALIASES GLOBALES PARA COMPATIBILIDAD
-- ============================================================================
function WCS_BrainMajorDemons_IsMajorDemon()
return WCS_BrainMajorDemons:IsMajorDemon()
end
function WCS_BrainMajorDemons_GetDemonType()
return WCS_BrainMajorDemons:GetDemonTypePublic()
end
function WCS_BrainMajorDemons_GetTimeRemaining()
return WCS_BrainMajorDemons:GetTimeRemainingPublic()
end
-- ============================================================================
-- FRAME DE ACTUALIZACION
-- ============================================================================
MajorDemons.frame = CreateFrame("Frame", "WCS_BrainMajorDemonsFrame")
MajorDemons.frame.elapsed = 0
MajorDemons.frame:SetScript("OnUpdate", function()
this.elapsed = this.elapsed + arg1
if this.elapsed >= 1.0 then
this.elapsed = 0
MajorDemons:Update()
end
end)
-- ============================================================================
-- COMANDOS SLASH
-- ============================================================================
SLASH_MAJORDEMONS1 = "/majordemons"
SLASH_MAJORDEMONS2 = "/md"
SlashCmdList["MAJORDEMONS"] = function(msg)
if not msg then
msg = ""
end
local cmd = string.lower(msg)
if cmd == "" or cmd == "status" then
if MajorDemons.State.currentDemon then
local timeLeft = MajorDemons:GetTimeRemaining()
MajorDemons:Print("Demonio actual: |cff00ff00" .. MajorDemons.State.currentDemon .. "|r")
MajorDemons:Print("Tiempo restante: " .. string.format("%.0f", timeLeft) .. " segundos")
else
MajorDemons:Print("No hay demonio mayor activo")
end
elseif cmd == "debug" then
MajorDemons.debug = not MajorDemons.debug
local status = "OFF"
if MajorDemons.debug then
status = "ON"
end
MajorDemons:Print("Debug: " .. status)
elseif cmd == "test" then
MajorDemons:Print("=== Test de Deteccion de Demonios Mayores ===")
local detected = MajorDemons:DetectMajorDemon()
if detected then
MajorDemons:Print("Detectado: |cff00ff00" .. detected .. "|r")
else
MajorDemons:Print("Detectado: |cffff0000Ninguno|r")
end
if UnitExists("pet") then
local petName = UnitName("pet")
if petName then
MajorDemons:Print("Nombre pet: " .. petName)
end
local petMana = UnitManaMax("pet")
if petMana then
MajorDemons:Print("Mana max pet: " .. petMana)
end
local petHP = UnitHealthMax("pet")
if petHP then
MajorDemons:Print("HP max pet: " .. petHP)
end
else
MajorDemons:Print("No hay mascota activa")
end
elseif cmd == "help" then
MajorDemons:Print("Comandos disponibles:")
MajorDemons:Print(" /md status - Ver estado actual")
MajorDemons:Print(" /md debug - Toggle modo debug")
MajorDemons:Print(" /md test - Probar deteccion")
else
MajorDemons:Print("Comando desconocido. Usa /md help")
end
end
-- ============================================================================
-- INICIALIZACION
-- ============================================================================
MajorDemons:Print("v" .. MajorDemons.VERSION .. " cargado")