@@ -323,6 +323,11 @@ function cast:castSpell(Unit, SpellID, FacingCheck, MovementCheck, SpamAllowed,
323323 if noCast then
324324 return true
325325 else
326+ -- Store pre-cast state to verify cast success
327+ local gcdBefore = br .functions .spell :getSpellCD (61304 ) -- GCD spell
328+ local castingBefore = br ._G .UnitCastingInfo (" player" ) ~= nil
329+ local channelingBefore = br ._G .UnitChannelInfo (" player" ) ~= nil
330+
326331 br .timersTable [SpellID ] = br ._G .GetTime ()
327332 -- currentTarget = UnitGUID(Unit) -- Not Used
328333 br .botCast = true -- Used by old Queue Cast
@@ -332,21 +337,43 @@ function cast:castSpell(Unit, SpellID, FacingCheck, MovementCheck, SpamAllowed,
332337 local X , Y , Z = br ._G .ObjectPosition (Unit )
333338 br ._G .ClickPosition (X , Y , Z )
334339 end
335- -- lastSpellCast = SpellID
336- -- change main button icon
337- -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
338- br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
339- br .lastSpellCast = SpellID
340- br .lastSpellTarget = br ._G .UnitGUID (Unit )
341- -- end
342- return true
340+
341+ -- Verify cast actually started
342+ local gcdAfter = br .functions .spell :getSpellCD (61304 )
343+ local castingAfter = br ._G .UnitCastingInfo (" player" ) ~= nil
344+ local channelingAfter = br ._G .UnitChannelInfo (" player" ) ~= nil
345+
346+ -- Cast succeeded if: GCD triggered OR started casting OR started channeling
347+ local castSucceeded = (gcdAfter > gcdBefore ) or
348+ (castingAfter and not castingBefore ) or
349+ (channelingAfter and not channelingBefore )
350+
351+ if castSucceeded then
352+ -- lastSpellCast = SpellID
353+ -- change main button icon
354+ -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
355+ br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
356+ br .lastSpellCast = SpellID
357+ br .lastSpellTarget = br ._G .UnitGUID (Unit )
358+ -- end
359+ return true
360+ else
361+ -- Cast failed - reset timer to allow retry
362+ br .timersTable [SpellID ] = nil
363+ return false
364+ end
343365 end
344366 end
345367 end
346368 elseif (FacingCheck == true or br .functions .unit :getFacing (" player" , Unit ) == true ) and (br .functions .unit :GetUnitIsUnit (" player" , Unit ) or br .engines .enemiesEngine .units [Unit ] ~= nil or br .functions .misc :getLineOfSight (" player" , Unit ) == true ) then
347369 if noCast then
348370 return true
349371 else
372+ -- Store pre-cast state to verify cast success
373+ local gcdBefore = br .functions .spell :getSpellCD (61304 ) -- GCD spell
374+ local castingBefore = br ._G .UnitCastingInfo (" player" ) ~= nil
375+ local channelingBefore = br ._G .UnitChannelInfo (" player" ) ~= nil
376+
350377 -- currentTarget = UnitGUID(Unit) -- Not Used
351378 br .botCast = true
352379 br .botSpell = SpellID
@@ -355,12 +382,28 @@ function cast:castSpell(Unit, SpellID, FacingCheck, MovementCheck, SpamAllowed,
355382 local X , Y , Z = br ._G .ObjectPosition (Unit )
356383 br ._G .ClickPosition (X , Y , Z )
357384 end
358- -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
359- br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
360- br .lastSpellCast = SpellID
361- br .lastSpellTarget = br ._G .UnitGUID (Unit )
362- -- end
363- return true
385+
386+ -- Verify cast actually started
387+ local gcdAfter = br .functions .spell :getSpellCD (61304 )
388+ local castingAfter = br ._G .UnitCastingInfo (" player" ) ~= nil
389+ local channelingAfter = br ._G .UnitChannelInfo (" player" ) ~= nil
390+
391+ -- Cast succeeded if: GCD triggered OR started casting OR started channeling
392+ local castSucceeded = (gcdAfter > gcdBefore ) or
393+ (castingAfter and not castingBefore ) or
394+ (channelingAfter and not channelingBefore )
395+
396+ if castSucceeded then
397+ -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
398+ br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
399+ br .lastSpellCast = SpellID
400+ br .lastSpellTarget = br ._G .UnitGUID (Unit )
401+ -- end
402+ return true
403+ else
404+ -- Cast failed - don't set lastSpellCast
405+ return false
406+ end
364407 end
365408 end
366409 end
@@ -426,32 +469,75 @@ function cast:castSpellMacro(Unit, SpellID, FacingCheck, MovementCheck, SpamAllo
426469 if noCast then
427470 return true
428471 else
472+ -- Store pre-cast state to verify cast success
473+ local gcdBefore = br .functions .spell :getSpellCD (61304 ) -- GCD spell
474+ local castingBefore = br ._G .UnitCastingInfo (" player" ) ~= nil
475+ local channelingBefore = br ._G .UnitChannelInfo (" player" ) ~= nil
476+
429477 br .timersTable [SpellID ] = br ._G .GetTime ()
430478 br .currentTarget = br ._G .UnitGUID (Unit )
431479 br ._G .RunMacroText (" /cast [@" .. Unit .. " ] " .. br ._G .GetSpellInfo (SpellID ))
432- -- lastSpellCast = SpellID
433- -- change main button icon
434- -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
435- br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
436- br .lastSpellCast = SpellID
437- br .lastSpellTarget = br ._G .UnitGUID (Unit )
438- -- end
439- return true
480+
481+ -- Verify cast actually started
482+ local gcdAfter = br .functions .spell :getSpellCD (61304 )
483+ local castingAfter = br ._G .UnitCastingInfo (" player" ) ~= nil
484+ local channelingAfter = br ._G .UnitChannelInfo (" player" ) ~= nil
485+
486+ -- Cast succeeded if: GCD triggered OR started casting OR started channeling
487+ local castSucceeded = (gcdAfter > gcdBefore ) or
488+ (castingAfter and not castingBefore ) or
489+ (channelingAfter and not channelingBefore )
490+
491+ if castSucceeded then
492+ -- lastSpellCast = SpellID
493+ -- change main button icon
494+ -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
495+ br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
496+ br .lastSpellCast = SpellID
497+ br .lastSpellTarget = br ._G .UnitGUID (Unit )
498+ -- end
499+ return true
500+ else
501+ -- Cast failed - reset timer to allow retry
502+ br .timersTable [SpellID ] = nil
503+ return false
504+ end
440505 end
441506 end
442507 end
443508 elseif (FacingCheck == true or br .functions .unit :getFacing (" player" , Unit ) == true ) and (br .functions .unit :GetUnitIsUnit (" player" , Unit ) or br .functions .misc :getLineOfSight (" player" , Unit ) == true ) then
444509 if noCast then
445510 return true
446511 else
512+ -- Store pre-cast state to verify cast success
513+ local gcdBefore = br .functions .spell :getSpellCD (61304 ) -- GCD spell
514+ local castingBefore = br ._G .UnitCastingInfo (" player" ) ~= nil
515+ local channelingBefore = br ._G .UnitChannelInfo (" player" ) ~= nil
516+
447517 br .currentTarget = br ._G .UnitGUID (Unit )
448518 br ._G .RunMacroText (" /cast [@" .. Unit .. " ] " .. br ._G .GetSpellInfo (SpellID ))
449- -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
450- br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
451- br .lastSpellCast = SpellID
452- br .lastSpellTarget = br ._G .UnitGUID (Unit )
453- -- end
454- return true
519+
520+ -- Verify cast actually started
521+ local gcdAfter = br .functions .spell :getSpellCD (61304 )
522+ local castingAfter = br ._G .UnitCastingInfo (" player" ) ~= nil
523+ local channelingAfter = br ._G .UnitChannelInfo (" player" ) ~= nil
524+
525+ -- Cast succeeded if: GCD triggered OR started casting OR started channeling
526+ local castSucceeded = (gcdAfter > gcdBefore ) or
527+ (castingAfter and not castingBefore ) or
528+ (channelingAfter and not channelingBefore )
529+
530+ if castSucceeded then
531+ -- if br.functions.misc:getOptionCheck("Start/Stop BadRotations") then
532+ br .ui .toggles .mainButton :SetNormalTexture (select (3 , br ._G .GetSpellInfo (SpellID )))
533+ br .lastSpellCast = SpellID
534+ br .lastSpellTarget = br ._G .UnitGUID (Unit )
535+ -- end
536+ return true
537+ else
538+ -- Cast failed - don't set lastSpellCast
539+ return false
540+ end
455541 end
456542 end -- End Spam Check
457543 end -- End CD/Distance Check
@@ -714,6 +800,13 @@ function cast:createCastFunction(thisUnit, castType, minUnits, effectRng, spellI
714800 if br ._G .UnitHealth (thisUnit ) > 0 or castType == " dead" then
715801 -- Debug Only
716802 if debug then return true end
803+
804+ -- Store pre-cast state to verify cast success
805+ local gcdBefore = br .functions .spell :getSpellCD (61304 ) -- GCD spell
806+ local spellCDBefore = br .functions .spell :getSpellCD (spellID ) -- This spell's CD
807+ local castingBefore = br ._G .UnitCastingInfo (" player" ) ~= nil
808+ local channelingBefore = br ._G .UnitChannelInfo (" player" ) ~= nil
809+
717810 -- Cast Spell
718811 br .botCast = true -- Used by old Queue Cast
719812 br .botSpell = spellID -- Used by old Queue Cast
@@ -727,14 +820,32 @@ function cast:createCastFunction(thisUnit, castType, minUnits, effectRng, spellI
727820 local X , Y , Z = br ._G .ObjectPosition (thisUnit )
728821 br ._G .ClickPosition (X , Y , Z )
729822 end
730- -- add to cast timer
731- castTimers [spellID ] = br ._G .GetTime () + 1
732- -- change main button icon
733- br .ui .toggles .mainButton :SetNormalTexture (icon )
734- -- Update Last Cast
735- br .lastSpellCast = spellID
736- br .lastSpellTarget = br ._G .UnitGUID (thisUnit )
737- return true
823+
824+ -- Verify cast actually started
825+ local gcdAfter = br .functions .spell :getSpellCD (61304 )
826+ local spellCDAfter = br .functions .spell :getSpellCD (spellID )
827+ local castingAfter = br ._G .UnitCastingInfo (" player" ) ~= nil
828+ local channelingAfter = br ._G .UnitChannelInfo (" player" ) ~= nil
829+
830+ -- Cast succeeded if: GCD triggered OR spell CD triggered OR started casting OR started channeling
831+ local castSucceeded = (gcdAfter > gcdBefore ) or
832+ (spellCDAfter > spellCDBefore ) or
833+ (castingAfter and not castingBefore ) or
834+ (channelingAfter and not channelingBefore )
835+
836+ if castSucceeded then
837+ -- add to cast timer
838+ castTimers [spellID ] = br ._G .GetTime () + 1
839+ -- change main button icon
840+ br .ui .toggles .mainButton :SetNormalTexture (icon )
841+ -- Update Last Cast
842+ br .lastSpellCast = spellID
843+ br .lastSpellTarget = br ._G .UnitGUID (thisUnit )
844+ return true
845+ else
846+ -- Cast failed - don't update timers or last cast
847+ return false
848+ end
738849 end
739850 return false
740851 end
0 commit comments