Index: BigTrouble.lua
===================================================================
--- BigTrouble.lua	(revision 29524)
+++ BigTrouble.lua	(working copy)
@@ -31,8 +31,8 @@
 }
 
 local reset_autoshot = {
-	[L["Aimed Shot"]] = true,
-	[L["Auto Shot"]] = true,
+	[L["Aimed Shot"]] = 1,
+	[L["Auto Shot"]] = 0,
 }
 
 local delay_autoshot = {
@@ -332,20 +332,35 @@
 	self:RegisterEvent("UNIT_SPELLCAST_FAILED", "SpellCastFailed")
 end
 
+function BigTrouble:SetDelay(newDelay)
+	if newDelay and newDelay > 0 then
+		self.master.Delay:SetText( string.format( "+%.1f", newDelay ) ) 
+		self.master.Delay:Show()
+	else
+		newDelay = nil
+		self.master.Delay:Hide()
+	end
+	self.delayTime = newDelay
+end
+
 function BigTrouble:SetupAutoShot(reset, forceDuration, delay)
 	if not self.db.profile.autoShotBar or not self.isAutoShot or self.isCasting then
 		return
 	end
+	local resetDelay = type(reset) == 'number' and reset or 0
 
-	if reset or not self.autoShotStart then
+	if reset then
 		self.autoShotStart = GetTime()
-		self.autoShotMaxValue = self.autoShotStart + (forceDuration or UnitRangedDamage("player"))
+		self.autoShotMaxValue = self.autoShotStart + (forceDuration or UnitRangedDamage("player")) + resetDelay
+		self.delayTime = nil	
 	end
 	
 	if delay and self.autoShotMaxValue then
 		local newMax = GetTime() + delay
 		if newMax > self.autoShotMaxValue then
-			self.autoShotStart = self.autoShotStart + newMax - self.autoShotMaxValue
+			local delayed = newMax - self.autoShotMaxValue
+			self:SetDelay((self.delayTime or 0) + delayed)
+			self.autoShotStart = self.autoShotStart + delayed
 			self.autoShotMaxValue = newMax
 		end
 	end
@@ -353,15 +368,20 @@
 	if self.autoShotMaxValue and GetTime() > self.autoShotMaxValue and not reset then
 		self.autoShotMaxValue = nil
 		self.autoShotStart = nil
-		return
 	end
 	
 	self.startTime = self.autoShotStart
 	self.maxValue = self.autoShotMaxValue
 	
+	if not self.autoShotStart then
+		self.thresHold = true
+		return
+	end
+	
 	local color = self.db.profile.colors.autoshot
 	self.master.Bar:SetStatusBarColor( color.r, color.g, color.b )
 	self:BarCreate(L["Auto Shot"])
+	self:SetDelay(self.delayTime)
 end
 
 function BigTrouble:SpellCastStart( unit )
@@ -369,6 +389,9 @@
 	
 	local name, _, text, _, startTime, endTime, _ = UnitCastingInfo(unit)
 	local bar = monitored_spells[name]
+	if bar and reset_autoshot[name] then
+		self.isAutoShot = true
+	end
 	if not bar or not self.db.profile[bar] then 
 		self.thresHold = ( bar == 'aimedShotBar' )
 		return 
@@ -379,6 +402,7 @@
 	
 	self.startTime = startTime / 1000
 	self.maxValue = endTime / 1000
+	self:SetDelay(nil)
 	self.isCasting = name
 	self:BarCreate( text )
 end
@@ -388,10 +412,10 @@
 
 	if self.isCasting and self.master:IsShown()	 then
 		self.isCasting = nil
+		self:SetDelay()
 		
 		self.master.Spark:Hide()
 		self.master.Time:Hide()
-		self.master.Delay:Hide()
 		
 		self.master.Bar:SetValue( self.maxValue )
 		local color = self.db.profile.colors.complete
@@ -421,7 +445,7 @@
 end
 
 function BigTrouble:SpellCastDelayed( unit )
-	if unit ~= "player" or spell ~= self.isCasting then return end
+	if unit ~= "player" or not self.isCasting then return end
  
 	if self.master:IsShown() then
 		local _, _, _, _, startTime, endTime, _, oldStart = UnitCastingInfo(unit)
@@ -430,17 +454,16 @@
 		self.startTime = startTime / 1000
 		self.maxValue = endTime / 1000
 		
-		self.delayTime = (self.delayTime or 0) + ( self.startTime - oldStart )
-		self.delayString = "+"..string.format( "%.1f", self.delayTime )
-		
-		self.master.Delay:Show()
+		self:SetDelay((self.delayTime or 0) + ( self.startTime - oldStart ))
 		self.master.Bar:SetMinMaxValues( self.startTime, self.maxValue )
 	end
 end
  
 function BigTrouble:StartAutoRepeat()
-	self.isAutoShot = true
-	self:SetupAutoShot(true, 0.5)
+	if not self.isAutoShot then
+		self.isAutoShot = true
+		self:SetupAutoShot(true, 0.5)
+	end
 end
 
 function BigTrouble:StopAutoRepeat()
@@ -456,7 +479,6 @@
 	self.master.Delay:SetText("")
 	
 	self.thresHold = nil
-	self.delayTime = nil
 	
 	self.master:Show()
 	self.master.Spark:Show()
@@ -590,7 +612,6 @@
 		BigTrouble.master.Spark:SetPoint("CENTER", BigTrouble.master.Bar, "LEFT", sparkProgress, 0)
 		
 		BigTrouble.master.Time:SetText( string.format( "%.1f", ( BigTrouble.maxValue - currentTime )))
-		if( BigTrouble.delayTime ~= nil ) then BigTrouble.master.Delay:SetText( BigTrouble.delayString ) end
 
 	else
 		local a = BigTrouble.master:GetAlpha() - .05
