Jump to content

  • Curse Sites
Help

In Combat script for Arenaframes with trinket


  • Please log in to reply
14 replies to this topic

#1 Nekrast

Nekrast
  • Members
  • Trollclass_name
  • EU-Dalvengyr
  • Vengeance / Rache
  • Posts: 3
  • Talents: Assassination

Posted 18 April 2013 - 02:43 PM

Hi, i Want a script that shows an icon next to the Targetframe/Focusframe and Arenaframes und show if Trinkets are Ready or not like sArena.. i found Woundmans script.. It works for Target and Focus Target.. but im not good enough in this stuff to add Arenaframes and Trinkets to Arenaframes

CTT=CreateFrame("Frame")CTT:SetParent(TargetFrame)CTT:SetPoint("Right",TargetFrame,0,5)CTT:SetSize(35,35)CTT.t=CTT:CreateTexture(nil,BORDER)CTT.t:SetAllPoints()CTT.t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")CTT:Hide()
			 local function FrameOnUpdate(self) if UnitAffectingCombat("target") then self:Show() else self:Hide() end end local g = CreateFrame("Frame") g:SetScript("OnUpdate", function(self) FrameOnUpdate(CTT) end)
			 CFT=CreateFrame("Frame")CFT:SetParent(FocusFrame)CFT:SetPoint("Right",FocusFrame,0,5)CFT:SetSize(35,35)CFT.t=CFT:CreateTexture(nil,BORDER)CFT.t:SetAllPoints()CFT.t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")CFT:Hide()
			 local function FrameOnUpdate(self) if UnitAffectingCombat("focus") then self:Show() else self:Hide() end end local g = CreateFrame("Frame") g:SetScript("OnUpdate", function(self) FrameOnUpdate(CFT) end)

Hope you can help me ;(

#2 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 18 April 2013 - 06:01 PM

here the code for the combat tracker!

LoadAddOn("Blizzard_ArenaUI")

for i = 1, 5 do
	_G["CT"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
	_G["CT"..i]:SetSize(25,25)
	_G["CT"..i]:SetPoint("RIGHT",15,0)
	_G["CT"..i].t = _G["CT"..i]:CreateTexture(nil,BORDER)
	_G["CT"..i].t:SetAllPoints()
	_G["CT"..i].t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
	_G["CT"..i]:Hide()

	_G["CT"..i]:SetScript("OnUpdate", function(self)
		if UnitAffectingCombat("arena"..i) then
			self:Show()
		else
			self:Hide()
		end
	end)
end


#3 Nekrast

Nekrast
  • Members
  • Trollclass_name
  • EU-Dalvengyr
  • Vengeance / Rache
  • Posts: 3
  • Talents: Assassination

Posted 18 April 2013 - 10:07 PM

Yea you are so Awesome man! So its not that hard to find a Trinket Tracker, now the question is can i put just all of them together in 1 Script via Copy/Paste?

#4 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 18 April 2013 - 11:19 PM

View PostNekrast, on 18 April 2013 - 10:07 PM, said:

Yea you are so Awesome man! So its not that hard to find a Trinket Tracker, now the question is can i put just all of them together in 1 Script via Copy/Paste?

yeah here is it:
LoadAddOn("Blizzard_ArenaUI")
for i = 1, 5 do
--(( TRINKET TRACKER ))--
		_G["TR"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
		_G["TR"..i]:SetSize(25,25)
		_G["TR"..i]:SetPoint("RIGHT",15,0)
		_G["TR"..i].t = _G["TR"..i]:CreateTexture(nil,BORDER)
		_G["TR"..i].t:SetAllPoints()
		_G["TR"..i].t:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01")
		_G["TR"..i].c = CreateFrame("Cooldown",nil,_G["TR"..i])
		_G["TR"..i].c:SetAllPoints(_G["TR"..i])
		_G["TR"..i]:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
		_G["TR"..i].unit = "arena"..i
		_G["TR"..i].timecheck = 0


		_G["TR"..i]:SetScript("OnEvent", function(self,event,unit,_,_,_,spellID)
			  local unitID = _G["TR"..i].unit
			  if unitID == unit then
					 if spellID == 59752 or spellID == 42292 then
							PlaySound("AlarmClockWarning3")
							self.c:SetCooldown(GetTime(),120)
							self.timecheck = GetTime()
					 elseif spellID == 7744 then
							if GetTime() - self.timecheck > 90 then
								   self.c:SetCooldown(GetTime(),30)
							elseif self.timecheck == 0 then
								   self.c:SetCooldown(GetTime(),30)
							end
					 end
			  end
	   end)

--(( COMBAT TRACKER ))--

		_G["CT"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
		_G["CT"..i]:SetSize(25,25)
		_G["CT"..i]:SetPoint("LEFT",_G["TR"..i],"RIGHT",5,0)
		_G["CT"..i].t = _G["CT"..i]:CreateTexture(nil,BORDER)
		_G["CT"..i].t:SetAllPoints()
		_G["CT"..i].t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
		_G["CT"..i]:Hide()
		_G["CT"..i]:SetScript("OnUpdate", function(self)
				if UnitAffectingCombat("arena"..i) then
						self:Show()
				else
						self:Hide()
				end
		end)
end


#5 Nekrast

Nekrast
  • Members
  • Trollclass_name
  • EU-Dalvengyr
  • Vengeance / Rache
  • Posts: 3
  • Talents: Assassination

Posted 19 April 2013 - 01:29 AM

well, Trinket is shown up fine, but incombat dualwield icon  never showed up.. am i doing something wrong? Well i found another one and tried to mix it up with your code.. with copy paste ehm because im noob...

That i found:
local CTT = CreateFrame("Frame", nil, TargetFrame)
CTT:SetPoint("Right", TargetFrame, 2, 5)
local CFT = CreateFrame("Frame", nil, FocusFrame)
CFT:SetPoint("Left", FocusFrame, -30, 5)
local frames = {
target = {CTT, "PLAYER_TARGET_CHANGED"},
focus = {CFT, "PLAYER_FOCUS_CHANGED"},
}
for k, v in pairs(frames) do
local f = v[1]
f:SetSize(30, 30)
f.t = f:CreateTexture(nil, "BORDER")
f.t:SetAllPoints()
f.t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
f:Hide()
f:SetScript("OnEvent", function(self, event, unit)
if unit == k or event == v[2] then
self[UnitAffectingCombat(k) and "Show" or "Hide"](self)
end
end)
f:RegisterEvent("UNIT_FLAGS")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("PLAYER_FOCUS_CHANGED")
end

That it ended up with:
LoadAddOn("Blizzard_ArenaUI")
for i = 1, 5 do
_G["CT"..i] = v[1]
_G["CT"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
_G["CT"..i]:SetSize(25,25)
_G["CT"..i]:SetPoint("RIGHT",15,0)
_G["CT"..i].t = _G["CT"..i]:CreateTexture(nil,BORDER)
_G["CT"..i].t:SetAllPoints()
_G["CT"..i].t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
_G["CT"..i]:Hide()
_G["CT"..i]:SetScript("OnEvent", function(self, event, unit)
if unit == 1, 5 or event == v[2] then
self[UnitAffectingCombat("arena"..i) and "Show" or "Hide"](self)
end
end)
_G["CT"..i]:RegisterEvent("UNIT_FLAGS")
_G["CT"..i]:RegisterEvent("PLAYER_TARGET_CHANGED")
_G["CT"..i]:RegisterEvent("PLAYER_FOCUS_CHANGED")
end

ill test when i get some1 to queue with lol.

*EDIT* dosnt work at all -.-

#6 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 20 April 2013 - 06:58 AM

View PostNekrast, on 19 April 2013 - 01:29 AM, said:

ill test when i get some1 to queue with lol.

*EDIT* dosnt work at all -.-

make the frame allways show up by changing the following to show where exactly the combat tracker frame is shown...
_G["CT"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
_G["CT"..i]:SetSize(25,25)
_G["CT"..i]:SetPoint("LEFT",_G["TR"..i],"RIGHT",5,0)
_G["CT"..i].t = _G["CT"..i]:CreateTexture(nil,BORDER)
_G["CT"..i].t:SetAllPoints()
_G["CT"..i].t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
-- _G["CT"..i]:Hide()
_G["CT"..i]:SetScript("OnUpdate", function(self)
if UnitAffectingCombat("arena"..i) then
self:Show()
else
-- self:Hide()
end
end)

now make a macro for showing up the arena frames out of arena and look if the combat tracker is shown and where exactly

/run ArenaEnemyFrames:Show(); for i = 1, 3 do _G"ArenaEnemyFrame"..i]:Show() end

the result:
Posted Image

so the frame exists and is shown up so far then the only problem is the onupdate function...
_G["CT"..i]:SetAlpha(0)
_G["CT"..i].unit = "arena"..i
_G["CT"..i]:SetScript("OnEvent", function(self)
if UnitExists(self.unit) then
if UnitAffectingCombat(self.unit) then
self:SetAlpha(1)
else
self:SetAlpha(0)
end
else
self:SetAlpha(0)
end
end)

and the better way of hiding the frame is with SetAlpha(0) instead of Hide()

#7 khanggle

khanggle
  • Members
  • Orcclass_name
  • US-Bleeding Hollow
  • Ruin
  • Posts: 18
  • Talents: Restoration 0/2/1/1/0/0
  • LocationToronto

Posted 22 April 2013 - 02:28 PM

View PostSyncrow, on 18 April 2013 - 11:19 PM, said:

yeah here is it:
LoadAddOn("Blizzard_ArenaUI")
for i = 1, 5 do
--(( TRINKET TRACKER ))--
	 _G["TR"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
	 _G["TR"..i]:SetSize(25,25)
	 _G["TR"..i]:SetPoint("RIGHT",15,0)
	 _G["TR"..i].t = _G["TR"..i]:CreateTexture(nil,BORDER)
	 _G["TR"..i].t:SetAllPoints()
	 _G["TR"..i].t:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01")
_G["TR"..i].c = CreateFrame("Cooldown",nil,_G["TR"..i])
_G["TR"..i].c:SetAllPoints(_G["TR"..i])
_G["TR"..i]:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
_G["TR"..i].unit = "arena"..i
_G["TR"..i].timecheck = 0


_G["TR"..i]:SetScript("OnEvent", function(self,event,unit,_,_,_,spellID)
local unitID = _G["TR"..i].unit
if unitID == unit then
if spellID == 59752 or spellID == 42292 then
PlaySound("AlarmClockWarning3")
self.c:SetCooldown(GetTime(),120)
self.timecheck = GetTime()
elseif spellID == 7744 then
if GetTime() - self.timecheck > 90 then
self.c:SetCooldown(GetTime(),30)
elseif self.timecheck == 0 then
self.c:SetCooldown(GetTime(),30)
end
end
end
end)

--(( COMBAT TRACKER ))--

_G["CT"..i] = CreateFrame("Frame",nil,_G["ArenaEnemyFrame"..i])
	 _G["CT"..i]:SetSize(25,25)
	 _G["CT"..i]:SetPoint("LEFT",_G["TR"..i],"RIGHT",5,0)
	 _G["CT"..i].t = _G["CT"..i]:CreateTexture(nil,BORDER)
	 _G["CT"..i].t:SetAllPoints()
	 _G["CT"..i].t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
	 _G["CT"..i]:Hide()
	 _G["CT"..i]:SetScript("OnUpdate", function(self)
			 if UnitAffectingCombat("arena"..i) then
					 self:Show()
			 else
					 self:Hide()
			 end
	 end)
end

Works great! Thank you!

I changed Show() and Hide() to SetAlpha 1 and 0 moved the trinket icon to (30,0) as to not overlap with the class icon. I did have one other nitpicky/ocd feature that I was trying to add but couldn't succeed: hiding the icon unless it's used by a player in arena? My previous trinket tracker code used:

function events:PLAYER_ENTERING_WORLD()
local _, instanceType = IsInInstance()
if instanceType == "arena" then
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
for _, trinket in pairs(trinkets) do
trinket:SetCooldown(0, 0)
trinket:SetAlpha(0)
end
end
end


#8 sarma

sarma
  • Junkies
  • Humanclass_name
  • EU-Sylvanas
  • Rampage / Saccage
  • Posts: 246
  • Talents: Frost 1/0/2/0/0/2
  • 2v2: 1745
  • 3v3: 2327
  • 5v5: 288
  • RBG: 192
  • LocationSerbia

Posted 22 April 2013 - 03:06 PM

Is it possible to position those arena frames to be on left side of screen mirrored?
Posted Image

#9 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 23 April 2013 - 03:37 AM

View Postkhanggle, on 22 April 2013 - 02:28 PM, said:

Works great! Thank you!

I changed Show() and Hide() to SetAlpha 1 and 0 moved the trinket icon to (30,0) as to not overlap with the class icon. I did have one other nitpicky/ocd feature that I was trying to add but couldn't succeed: hiding the icon unless it's used by a player in arena? My previous trinket tracker code used:

function events:PLAYER_ENTERING_WORLD()
local _, instanceType = IsInInstance()
if instanceType == "arena" then
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
for _, trinket in pairs(trinkets) do
trinket:SetCooldown(0, 0)
trinket:SetAlpha(0)
end
end
end

add an on update function to the trinket tracker and it will show only when used and on cooldown otherwise hided..

_G["TR"..i]:SetScript("OnUpdate", function(self)
	if self.timecheck > 0 then
		self:SetAlpha(1)
	else
		self:SetAlpha(0)
	end
end)

PS: hope you switched the sound on and noticed that each time a trinket is forced you will hear a "bling"! so you know instantly that a trinket is forced even if you not show to the track frame x)

#10 Gravestoner

Gravestoner
  • Members
  • Posts: 6

Posted 15 July 2013 - 09:42 PM

What I've bee trying to do and failing is for the Combat Tracker portion of code. Using a SetScript("OnEvent") instead of "OnUpdate", and then registering events that would put that target in combat to start/reset a Cooldown Timer over the DualWield icon. So that the Cooldown Timer will run out right as the target drops combat.

Anythoughts?

#11 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 16 July 2013 - 07:22 AM

View PostGravestoner, on 15 July 2013 - 09:42 PM, said:

What I've bee trying to do and failing is for the Combat Tracker portion of code. Using a SetScript("OnEvent") instead of "OnUpdate", and then registering events that would put that target in combat to start/reset a Cooldown Timer over the DualWield icon. So that the Cooldown Timer will run out right as the target drops combat.

Anythoughts?
What we know about combat and combat resetting:
  • you are going into combat after being hit
  • you are in combat for 6 sec after the last hit
  • after 6 seconds, your combat status reset, until you are not taken dmg / being hit again
the problem about this is, that there is no unit event that was fired for the last hit, so we can't easily calculate the 6 sec down to out of combat...

we "could" use the combat_event_unfiltered to track "each" hit that let the target being in combat...and calculate the 6 sec down... and if the 6 sec run out without reapplying so the countdown goes to zero...the frame will be hiding..but this will takes a lot of memory...cause we have to track near each argument for combat_event_unfiltered.

#12 Gravestoner

Gravestoner
  • Members
  • Posts: 6

Posted 16 July 2013 - 10:11 AM

What About "UNIT_COMBAT" event?

Fired when an npc or player participates in combat and takes damage
arg1 the UnitID of the entity
arg2 Action,Damage,etc (e.g. HEAL, DODGE, BLOCK, WOUND, MISS, PARRY, RESIST, ...)
arg3 Critical/Glancing indicator (e.g. CRITICAL, CRUSHING, GLANCING)
arg4 The numeric damage
arg5 Damage type in numeric value (1 - physical; 2 - holy; 4 - fire; 8 - nature; 16 - frost; 32 - shadow; 64 - arcane)

#13 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 16 July 2013 - 12:32 PM

View PostGravestoner, on 16 July 2013 - 10:11 AM, said:

What About "UNIT_COMBAT" event?

Fired when an npc or player participates in combat and takes damage
arg1 the UnitID of the entity
arg2 Action,Damage,etc (e.g. HEAL, DODGE, BLOCK, WOUND, MISS, PARRY, RESIST, ...)
arg3 Critical/Glancing indicator (e.g. CRITICAL, CRUSHING, GLANCING)
arg4 The numeric damage
arg5 Damage type in numeric value (1 - physical; 2 - holy; 4 - fire; 8 - nature; 16 - frost; 32 - shadow; 64 - arcane)

we want to track if someone is not affecting combat or goes it..this event is fired exactly in the opposite way..we could use it maybe in excange for combat log unfiltered, but i'm not sure it will fire once the unit is even affecting combat...

#14 Gravestoner

Gravestoner
  • Members
  • Posts: 6

Posted 16 July 2013 - 07:26 PM

Try this

Quote

local f = CreateFrame("Frame") f:RegisterEvent("UNIT_COMBAT") f:SetScript("OnEvent",function(self,event,U,...) if U == "target" then print("CombatTimerReset") end end)
It keeps printing every time you take action that would put you in combat, even if you are already in combat. I want to use this simply as a trigger to start a 5-6 sec cooldown timer, and every time it triggers it resets the cooldown animation.

#15 Syncrow

Syncrow
  • Premium
  • Curse Premium
  • Posts: 179

Posted 17 July 2013 - 01:15 PM

View PostGravestoner, on 16 July 2013 - 07:26 PM, said:

Try this
It keeps printing every time you take action that would put you in combat, even if you are already in combat. I want to use this simply as a trigger to start a 5-6 sec cooldown timer, and every time it triggers it resets the cooldown animation.

here it is:
local f = CreateFrame("Frame",nil,TargetFrame)
f:SetSize(30,30)
f:SetPoint("LEFT",TargetFrame,"RIGHT",-10,0)
f.t = f:CreateTexture(nil,"BACKGROUND")
f.t:SetAllPoints()
f.t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD")
f.c = CreateFrame("Cooldown",nil,f)
f.c:SetAllPoints(f)
f:RegisterUnitEvent("UNIT_COMBAT","target")
f:SetAlpha(0)
----
f:SetScript("OnEvent", function(s, e, u, ...)
	s.c:SetCooldown(GetTime(), 6)
end)
----
f:SetScript("OnUpdate", function(s)
	if UnitAffectingCombat("target") then
		s:SetAlpha(1)
	else
		s:SetAlpha(0)
	end
end)

you can also use "COMBAT_LOG_EVENT_UNFILTERED":
f:SetScript("OnEvent", function(s, e, ...)
	if select(8, ...) == UnitGUID("target") then
		s.c:SetCooldown(GetTime(), 6)
	end
end)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

<