Advertisement
Guest User

Untitled

a guest
Apr 12th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.26 KB | None | 0 0
  1. --master toggle
  2. local msTog=false
  3. local plyr=UnitName('player')
  4. local bheight=-100
  5. local faction=UnitFactionGroup('player')
  6. local train_state='off'
  7.  -- character init
  8. local dev_mode=false -- will reset player stats every /reload if 'true'
  9. local btn_sz=30
  10. local btn_szx=34
  11. local btn_szy=50
  12. local hh=UnitSex('player')
  13. local hisher={'their', 'his', 'her'}
  14. local hb_wid=139
  15. local tW=900
  16. local tH=200
  17. local accepting_combat=true
  18. local able_combat=true
  19. local cooldown=false
  20. local function tbar(x) end
  21. local function trainTggl() end
  22. local colors={
  23.     Strength={r=1, g=.2, b=.2},
  24.     Charisma={r=1, g=1, b=.2},
  25.     Wisdom={r=.6, g=.6, b=.2},
  26.     Dexterity={r=.6, g=1, b=.4},
  27.     Intelligence={r=.8, g=.3, b=1},
  28.     reset={r=.1, g=1, b=.7},
  29.     white={r=1, g=1, b=1},
  30.     black={r=0, g=0, b=0},
  31.     warn={r=1, g=.7, b=.2}
  32. }
  33. local hand='Interface\\CURSOR\\openhand'
  34. local point='Interface\\CURSOR\\Point'
  35. local ping='Sound\\Interface\\PickUp\\PutDownRing.ogg'
  36. local d20='Sound\\DOODAD\\FX_BoardTilesDice_04.OGG'
  37. local wound={
  38.     '',
  39.     'Sound\\character\\Human\\Male\\HumanMaleWoundB.ogg',
  40.     'Sound\\character\\DraeneiFemalePC\\DraeneiFemalePCWoundG.ogg'
  41. }
  42. local function rcol(x)
  43.     return math.random(x, 10)/10
  44. end
  45.  
  46. local pending={}
  47.  
  48. local cathedral={.499, .453}
  49. local spirits={.327, .648}
  50.  
  51. local the_log=''
  52. local optArr={}
  53. optArr[1]={'',{1,1,1}}
  54. optArr[2]={'',{1,1,1}}
  55. optArr[3]={'',{1,1,1}}
  56. optArr[4]={'',{1,1,1}}
  57. local function prnt(x, col)
  58.     -- local col={rcol(1),rcol(1),rcol(1)}
  59.     -- print(col.r, col.g)
  60.     if col==nil then col=colors.white end
  61.     local opt=#optArr
  62.     local insert={x, col}
  63.     table.insert(optArr, 1, insert)
  64.     -- print(optArr[1][1],optArr[1][2])
  65.     table.remove(optArr, opt+1)
  66.     -- the_log=optArr[4]..'\n'..optArr[3]..'\n'..optArr[2]..'\n'..optArr[1]..'\n'
  67.     for k,v in pairs(optArr) do
  68.         textFr.txt[k]:SetText(optArr[k][1])
  69.         textFr.txt[k]:SetTextColor(optArr[k][2].r,optArr[k][2].g,optArr[k][2].b)
  70.     end
  71. end
  72.  
  73. local function dist(a, b)
  74.     local c;
  75.     local x, y=GetPlayerMapPosition("player");
  76.     if x~=nil and y~=nil then
  77.         c=math.sqrt(((a-x)*(a-x))+((b-y)*(b-y)));
  78.     else c=99999
  79.     end
  80.     return c
  81. end
  82.  
  83.  
  84.  
  85.     local GHFlashFrame
  86.     local flashAnims, isAni
  87.     -- ** color is {r=1,g=1,b=1 **}
  88.     local ffrm = function(fadeIn, fadeOut, duration, color, alpha, texture, blend, repeating)
  89.         local blendTypes = {"ADD","BLEND","MOD","ALPHAKEY","DISABLE"}
  90.         if alpha == 1 then alpha = 0.99 end
  91.  
  92.         if not (color) and not (texture) then
  93.  
  94.                 print("You must define a texture or color.")
  95.         return
  96.         end
  97.  
  98.         local delay = duration - (fadeIn + fadeOut)
  99.         if repeating == nil then
  100.             repeating = 1
  101.         end
  102.  
  103.         if not (GHFlashFrame) then
  104.             GHFlashFrame = CreateFrame("Frame", "GHFlashFrame", UIParent);
  105.             GHFlashFrame:SetFrameStrata("BACKGROUND");
  106.             GHFlashFrame:SetAllPoints(UIParent);
  107.             GHFlashFrame.bg = GHFlashFrame:CreateTexture(nil, "CENTER")
  108.             GHFlashFrame.bg:SetAllPoints(GHFlashFrame)
  109.         end
  110.         if not (flashAnims) then
  111.             flashAnims = GHFlashFrame:CreateAnimationGroup("Flashing")
  112.             flashAnims.fadingIn = flashAnims:CreateAnimation("Alpha")
  113.             flashAnims.fadingIn:SetOrder(1)
  114.             flashAnims.fadingIn:SetSmoothing("NONE")
  115.             flashAnims.fadingIn:SetToAlpha(1)
  116.            
  117.             flashAnims.fadingOut = flashAnims:CreateAnimation("Alpha")
  118.             flashAnims.fadingOut:SetOrder(2)
  119.             flashAnims.fadingOut:SetSmoothing("NONE")
  120.             flashAnims.fadingOut:SetFromAlpha(1)
  121.            
  122.             flashAnims:SetScript("OnFinished",function(self,requested)
  123.                 GHFlashFrame:Hide()
  124.                 GHFlashFrame.bg:SetBlendMode("DISABLE")
  125.                 isAni = false
  126.             end)
  127.             flashAnims:SetScript("OnPlay",function(self)
  128.                 GHFlashFrame:Show()
  129.                 GHFlashFrame:SetAlpha(0)
  130.                 isAni = true
  131.             end)
  132.         end
  133.  
  134.         flashAnims.fadingIn:SetDuration(fadeIn)
  135.         flashAnims.fadingIn:SetEndDelay(delay)
  136.         flashAnims.fadingOut:SetDuration(fadeOut)
  137.         if repeating > 1 then
  138.             flashAnims:SetLooping("REPEAT")
  139.         else
  140.             flashAnims:SetLooping("NONE")
  141.         end
  142.         local timestart = GetTime()
  143.         local looptime = duration * repeating
  144.  
  145.         flashAnims:SetScript("OnLoop", function(self, loopstate)
  146.             if loopstate == "FORWARD" then
  147.                 local curtime = GetTime()
  148.                 if difftime(curtime, timestart) == looptime - duration then
  149.                     flashAnims:SetLooping("NONE")
  150.                 end
  151.             end
  152.         end)
  153.  
  154.         if texture then
  155.             GHFlashFrame.bg:SetTexture(texture)
  156.             GHFlashFrame.bg:SetBlendMode(blend or "ADD")
  157.             GHFlashFrame.bg:SetAlpha(alpha or 1)
  158.             flashAnims.fadingIn:SetToAlpha(alpha or 1)
  159.             flashAnims.fadingOut:SetFromAlpha(alpha or 1)
  160.  
  161.             if color then
  162.                 GHFlashFrame.bg:SetVertexColor(
  163.                         color.r or color[1],
  164.                         color.g or color[2],
  165.                         color.b or color[3]
  166.                     )
  167.             else
  168.                 GHFlashFrame.bg:SetVertexColor(1,1,1,1)
  169.             end
  170.         else
  171.             if not (blend) then
  172.                 blend = 5
  173.             end
  174.             GHFlashFrame.bg:SetColorTexture(color.r or color[1], color.g or color[2], color.b or color[3])
  175.             GHFlashFrame.bg:SetBlendMode(blendTypes[blend])
  176.             GHFlashFrame.bg:SetAlpha(alpha or 1)
  177.         end
  178.  
  179.         if isAni == true then -- if sone is already animating, stop it and do the new one
  180.             GHFlashFrame:StopAnimating()
  181.             GHFlashFrame.bg:SetAlpha(0)
  182.             flashAnims.fadingIn:SetToAlpha(alpha or 1)
  183.             flashAnims.fadingOut:SetFromAlpha(alpha or 1)
  184.             flashAnims:Play()
  185.         else -- otherwise animate
  186.             flashAnims.fadingIn:SetToAlpha(alpha or 1)
  187.             flashAnims.fadingOut:SetFromAlpha(alpha or 1)
  188.             flashAnims:Play()
  189.         end
  190.     end
  191.  
  192.  
  193.  
  194. -- if self, Tyler Durden
  195. local function RlPl_roll(cat, pos, opp)
  196.     local dst_ck=false
  197.     if UnitIsPlayer(opp) then
  198.         dst_ck=CheckInteractDistance(opp, 3)
  199.     else
  200.         dst_ck=CheckInteractDistance('target', 3)
  201.     end
  202.     if dst_ck==true then
  203.         cooldown=true
  204.         C_Timer.After(5, function() cooldown=false end)
  205.         local id,name=GetChannelName('xtensionxtooltip2')
  206.         local roll=math.random(1,20)+Rllply[cat]
  207.         if pos=='atk' then
  208.             prnt('You attack '..opp..': '..roll, colors.white)
  209.             pending[opp]=roll
  210.         end
  211.         if pos=='dfd' then
  212.             prnt('You roll: '..roll..' in defense against '..opp, colors.white)
  213.         end
  214.         SendChatMessage('RlPl '..cat..' '..pos..' '..opp..' '..roll, 'CHANNEL', nil, id)
  215.     else
  216.         prnt('Too far!', colors.Strength)
  217.     end
  218. end
  219.  
  220. local rlpl_stats={
  221.     str=1,
  222.     int=1,
  223.     chr=1,
  224.     wis=1,
  225.     dex=1,
  226.     health=10,
  227.     train=10
  228. }
  229. local cats={
  230.     str='Strength',
  231.     int='Intelligence',
  232.     chr='Charisma',
  233.     wis='Wisdom',
  234.     dex='Dexterity'
  235. }
  236.  
  237. local mPane=CreateFrame("Frame", nil, UIParent)
  238. mPane:SetSize(40, 40)
  239. mPane:SetPoint('TOP', UIParent, 'TOP')
  240. mPane:RegisterEvent('ADDON_LOADED')
  241. mPane:RegisterEvent('PLAYER_LOGOUT')
  242. -- mPane:SetMovable(true)
  243. -- mPane:EnableMouse(true)
  244. -- mPane:RegisterForDrag("LeftButton")
  245. -- mPane:SetScript("OnDragStart", mPane.StartMoving)
  246. -- mPane:SetScript("OnDragStop", mPane.StopMovingOrSizing)
  247. -- mPane:SetScript("OnEnter", function() SetCursor(hand) end)
  248. -- mPane:SetScript("OnLeave", function() SetCursor(point) end)
  249.  
  250. mPane.tggl=CreateFrame("Button", nil, mPane, "SecureHandlerClickTemplate" )
  251. mPane.tggl:SetSize(30, 30)
  252. mPane.tggl:SetPoint("TOP", mPane, "TOP", 0, -30)
  253. mPane.tggl:RegisterForClicks("AnyUp")
  254. mPane.tggl:SetNormalTexture("Interface\\BUTTONS\\UI-GroupLoot-Dice-Up")
  255. mPane.tggl:SetPushedTexture("Interface\\BUTTONS\\UI-GroupLoot-Dice-Up")
  256. mPane.tggl:SetHighlightTexture("Interface\\BUTTONS\\GLOWSTAR")
  257. mPane.tggl:SetMovable(true)
  258. mPane.tggl:EnableMouse(true)
  259. mPane.tggl:RegisterForDrag("LeftButton")
  260. mPane.tggl:SetScript("OnDragStart", mPane.StartMoving)
  261. mPane.tggl:SetScript("OnDragStop", mPane.StopMovingOrSizing)
  262.  
  263. mPane.bg=mPane:CreateTexture()
  264. mPane.bg:SetTexture('Interface\\UNITPOWERBARALT\\MetalBronze_Circular_Frame')
  265. mPane.bg:SetSize(55, 55)
  266. mPane.bg:SetPoint('CENTER', mPane.tggl, 'CENTER', 0, 5)
  267.  
  268. local UIShow=CreateFrame("Frame", nil, mPane)
  269. UIShow:SetSize(tW, tH)
  270. UIShow:SetPoint('TOP', mPane.tggl, 'TOP', 0, -10)
  271. local backdrop = {
  272.     bgFile = "Interface\\GLUES\\Models\\UI_MainMenu_Pandaria\\VEB_Cloud_static_01",
  273.     insets = {
  274.         left = 11,
  275.         right = 12,
  276.         top = 12,
  277.         bottom = 11
  278.     }
  279. }
  280. UIShow:SetBackdrop(backdrop)
  281. UIShow:SetBackdropColor(1, 1, 1, .8)
  282. UIShow:Hide()
  283.  
  284. local incFrRply=CreateFrame("Frame", nil, UIShow)
  285.  
  286.  
  287. local function RlPl_layout()
  288. textFr = CreateFrame("Frame",nil,UIShow)
  289. textFr:SetSize((tW/2)+40,150)
  290. textFr:SetPoint("LEFT",UIShow,"CENTER",-40,30)
  291.  
  292. textFr.bg=textFr:CreateTexture()
  293. textFr.bg:SetTexture('Interface\\GLUES\\Models\\UI_Worgen\\gradient5Circle')
  294. textFr.bg:SetSize(700, 300)
  295. textFr.bg:SetPoint('LEFT', UIShow, 'CENTER', -150, 0)
  296. textFr.bg:SetVertexColor(1, 1, 1, .7)
  297.  
  298. textFr.txt={}
  299. for k,v in pairs(optArr) do
  300.     textFr.txt[k] = textFr:CreateFontString()
  301.     textFr.txt[k]:SetPoint("BOTTOMLEFT",textFr,"BOTTOMLEFT",0,20*k)
  302.     textFr.txt[k]:SetFont('Interface\\Addons\\RollPlay\\FONTS\\IMFeENsc28P.TTF', 15, nil)
  303.     textFr.txt[k]:SetTextColor(1, 1, 1, .8)
  304.     textFr.txt[k]:SetText("")
  305.     -- textFr.txt[k]:SetSize(textFr:GetWidth(),textFr:GetHeight()+100)
  306.     textFr.txt[k]:SetSize(tW,20)
  307.     textFr.txt[k]:SetJustifyV("BOTTOM")
  308.     textFr.txt[k]:SetJustifyH("LEFT")
  309. end
  310.  
  311. incFrRply:SetSize(tW, tH)
  312. incFrRply:SetPoint('TOP', mPane, 'TOP')
  313.  
  314. -- UIShow.pool = UIShow:CreateFontString(nil, "OVERLAY");
  315. -- UIShow.pool:SetFont('Interface\\Addons\\RollPlay\\FONTS\\IMFeENsc28P.TTF', 15, nil);
  316. -- UIShow.pool:SetTextColor(.8, .2, .1, .8)
  317. -- UIShow.pool:SetPoint("LEFT", UIShow, "LEFT", 215, -55);
  318. -- UIShow.pool:SetText("Points remaining: "..Rllply.train);
  319.  
  320. -- local function ptcheck()
  321. --  if Rllply.train<=0 then
  322. --      -- UIShow.pool:Hide()
  323. --  end
  324. -- end
  325. -- ptcheck()
  326.  
  327. local hbar_L=200
  328. local hbar_V=30
  329. local tbar_L=hbar_L
  330. local tbar_V=hbar_V-30
  331. UIShow.h = CreateFrame("Frame", nil, UIShow)
  332. UIShow.h:SetPoint('TOP', UIShow, 'TOP', 0, 0)
  333. UIShow.h:SetSize(tW, tH)
  334. UIShow.h.fr=UIShow.h:CreateTexture('')
  335. UIShow.h.fr:SetTexture('Interface\\COMMON\\friendship-parts')
  336. UIShow.h.fr:SetSize(300, 40)
  337. UIShow.h.fr:SetPoint('TOPLEFT', UIShow.h, 'TOPLEFT', hbar_L+10, hbar_V-40)
  338. UIShow.h.fr:SetTexCoord(.01, 1, 0, 1)
  339. UIShow.h.fr:SetDrawLayer('BACKGROUND', 2)
  340.  
  341. UIShow.h.bg=UIShow.h:CreateTexture('')
  342. UIShow.h.bg:SetTexture('Interface\\BUTTONS\\YELLOWORANGE64')
  343. UIShow.h.bg:SetPoint('TOPLEFT', UIShow.h, 'TOPLEFT', hbar_L+26, hbar_V-51)
  344. UIShow.h.bg:SetSize(hb_wid, 9)
  345. UIShow.h.bg:SetDrawLayer('BACKGROUND', 1)
  346. UIShow.h.bg:SetVertexColor(.7, .2, .2)
  347.  
  348. UIShow.t = CreateFrame("Frame", nil, UIShow)
  349. UIShow.t:SetPoint('TOP', UIShow, 'TOP', 0, 0)
  350. UIShow.t:SetSize(tW, tH)
  351. UIShow.t.fr=UIShow.t:CreateTexture('')
  352. UIShow.t.fr:SetTexture('Interface\\COMMON\\friendship-parts')
  353. UIShow.t.fr:SetSize(300, 40)
  354. UIShow.t.fr:SetPoint('TOPLEFT', UIShow.t, 'TOPLEFT', tbar_L+10, tbar_V-40)
  355. UIShow.t.fr:SetTexCoord(.01, 1, 0, 1)
  356. UIShow.t.fr:SetDrawLayer('BACKGROUND', 2)
  357.  
  358. UIShow.t.bg=UIShow.t:CreateTexture('')
  359. UIShow.t.bg:SetTexture('Interface\\BUTTONS\\YELLOWORANGE64')
  360. UIShow.t.bg:SetPoint('TOPLEFT', UIShow.t, 'TOPLEFT', tbar_L+26, tbar_V-51)
  361. UIShow.t.bg:SetSize(hb_wid, 9)
  362. UIShow.t.bg:SetDrawLayer('BACKGROUND', 1)
  363. UIShow.t.bg:SetVertexColor(.9, .9, .4)
  364.  
  365. local resetS=CreateFrame("Button", nil, UIShow, "SecureHandlerClickTemplate")
  366. resetS:SetPoint('TOPLEFT', UIShow.t, 'TOPLEFT', tbar_L+10, tbar_V-42)
  367. resetS:SetSize(24, 24)
  368. resetS:SetNormalTexture("Interface\\COMMON\\Indicator-Yellow")
  369. resetS:SetPushedTexture("Interface\\COMMON\\Indicator-Red")
  370. resetS:SetHighlightTexture("Interface\\COMMON\\RingBorder")
  371. resetS:RegisterForClicks('AnyUp')
  372.  
  373. local resetH=CreateFrame("Button", nil, UIShow, "SecureHandlerClickTemplate")
  374. resetH:SetPoint('TOPLEFT', UIShow.h, 'TOPLEFT', hbar_L+11, hbar_V-40)
  375. resetH:SetSize(24, 24)
  376. resetH:SetNormalTexture("Interface\\COMMON\\friendship-heart")
  377. resetH:SetHighlightTexture("Interface\\COMMON\\RingBorder")
  378. resetH:RegisterForClicks('AnyUp')
  379.  
  380. local function hbar(x)
  381.     if x<=0 then x=1 end
  382.     if x>=rlpl_stats.health then x=rlpl_stats.health end
  383.     local z=(x/rlpl_stats.health)*hb_wid
  384.     UIShow.h.bg:SetSize(z, 9)
  385. end
  386.  
  387. function tbar(x)
  388.     if x<=0 then x=.01 end
  389.     if x>=rlpl_stats.train then
  390.         x=rlpl_stats.train
  391.  
  392.     end
  393.     local z=(x/10)*hb_wid
  394.     UIShow.t.bg:SetSize(z, 9)
  395. end
  396.  
  397. local catWidth=#cats * 50
  398. local function frCreate(cat, catNum, iconName)
  399.     UIShow[cat]=CreateFrame("Button", nil, UIShow, "SecureHandlerClickTemplate" )
  400.     UIShow[cat]:SetSize(btn_sz, btn_sz)
  401.     UIShow[cat]:SetPoint("TOP", UIShow, "TOP", -280+catNum*40, bheight)
  402.     UIShow[cat]:RegisterForClicks("AnyUp")
  403.     UIShow[cat]:SetNormalTexture("Interface\\ICONS\\"..iconName)
  404.     UIShow[cat]:SetPushedTexture("Interface\\BUTTONS\\UI-Quickslot-Depress")
  405.     UIShow[cat]:SetHighlightTexture("Interface\\BUTTONS\\GLOWSTAR")
  406.     UIShow[cat]:SetScript("OnClick", function()
  407.         local tgt=UnitName('target')
  408.         if tgt~=nil then
  409.             if Rllply.health>0 and able_combat==true then
  410.                 if cooldown==false then
  411.                     PlaySoundFile(d20)
  412.                     RlPl_roll(cat, 'atk', tgt)
  413.                 else
  414.                     ffrm(.3, .3, 1, colors.Dexterity, .5, nil, 5, nil)
  415.                     prnt('You must wait five seconds between attacks', colors.warn)
  416.                 end
  417.             else
  418.                 ffrm(.3, .3, 1, colors.Dexterity, .5, nil, 5, nil)
  419.                 prnt('You are too weakened to attack!', colors.warn)
  420.             end
  421.         else
  422.             SendChatMessage('uses their '..string.lower(cats[cat])..' to no avail.', 'EMOTE')
  423.         end
  424.     end)
  425.     UIShow[cat].name=UIShow:CreateFontString()
  426.     UIShow[cat].name:SetPoint("BOTTOM",UIShow[cat],"TOP",0,0)
  427.     UIShow[cat].name:SetFont('Interface\\Addons\\RollPlay\\FONTS\\IMFeENsc28P.TTF', 15, nil)
  428.     UIShow[cat].name:SetTextColor(.3, .2, .1, .8)
  429.     UIShow[cat].name:SetText(cats[cat]:sub(1,3)..":")
  430.     UIShow[cat].name:SetSize(100, 20)
  431.  
  432.     UIShow[cat].amt=UIShow:CreateFontString()
  433.     UIShow[cat].amt:SetPoint("TOP",UIShow[cat],"BOTTOM",0,2)
  434.     UIShow[cat].amt:SetFont("Interface\\Addons\\RollPlay\\FONTS\\IMFeENsc28P.TTF", 15, nil)
  435.     UIShow[cat].amt:SetTextColor(.1, .1, .1, .8)
  436.     UIShow[cat].amt:SetText(Rllply[cat])
  437.     UIShow[cat].amt:SetSize(100, 20)   
  438.  
  439.     UIShow[cat].inc=CreateFrame("Button", nil, incFrRply, "SecureHandlerClickTemplate")
  440.     UIShow[cat].inc:SetNormalTexture("Interface\\BUTTONS\\UI-MicroButton-BStore-Up")
  441.     UIShow[cat].inc:SetPushedTexture("Interface\\BUTTONS\\UI-MicroButton-BStore-Down")
  442.     UIShow[cat].inc:SetHighlightTexture('Interface\\BUTTONS\\GLOWSTAR')
  443.  
  444.     UIShow[cat].inc:SetPoint('BOTTOM', UIShow[cat], 'BOTTOM', 0, 0)
  445.     UIShow[cat].inc:SetSize(btn_szx, btn_szy)
  446.     UIShow[cat].inc:RegisterForClicks("AnyUp")
  447.     UIShow[cat].inc:SetScript("OnClick", function ()
  448.         if Rllply[cat]<5 and Rllply.train>=1 then
  449.             PlaySoundFile(ping)
  450.             Rllply[cat]=Rllply[cat]+1
  451.             Rllply.train=Rllply.train-1
  452.             tbar(Rllply.train)
  453.             UIShow[cat].amt:SetText(Rllply[cat])
  454.             if Rllply.train <= 0 then
  455.                 incFrRply:Hide() -- xyzzy
  456.             end
  457.         else
  458.             ffrm(.3, .3, 1, colors.Dexterity, .5, nil, 5, nil)
  459.             prnt('capped', colors.warn)        
  460.         end
  461.     end)
  462. end
  463.  
  464. -- frCreate('vit', 1, "PetBattle_Health")
  465. frCreate('str', 1, "Spell_Nature_Strength")
  466. frCreate('dex', 2, "INV_sword_1h_garrison_a_05")
  467. frCreate('chr', 3, "Spell_Shadow_Charm")
  468. frCreate('wis', 4, "TRADE_ARCHAEOLOGY_HIGHBORNE_SCROLL")
  469. frCreate('int', 5, "Spell_Shadow_Brainwash")
  470.  
  471. mPane.tggl:SetScript("OnClick", function ()
  472.     PlaySoundFile(d20)
  473.     if msTog==false then
  474.         UIShow:Show()
  475.         if UIShow:IsVisible()==false then
  476.             print('[RollPlay]: Can\'t toggle frame during spellcasting')
  477.         end
  478.         msTog=true
  479.         accepting_combat=true
  480.     else
  481.         UIShow:Hide()
  482.         if UIShow:IsVisible()==true then
  483.             print('[RollPlay]: Can\'t toggle frame during spellcasting')
  484.         end
  485.         msTog=false
  486.         accepting_combat=false
  487.     end
  488.     -- end
  489.  end)
  490.  
  491.  if Rllply.train<=0 then
  492.  --     UIShow.pool:Hide()
  493.     incFrRply:Hide()
  494.  --     for k,v in pairs(Rllply) do
  495.     --  if UIShow[k]~=nil then
  496.     --      UIShow[k].inc:SetWidth(0)
  497.     --  end
  498.     -- end
  499.  end
  500.  
  501. if Rllply.health<=0 then
  502.     able_combat=false
  503. end
  504. hbar(Rllply.health)
  505. tbar(Rllply.train)
  506.  
  507.  local function multyPlecksR(self, event, msg, snd, hm, cnName, shortName, hmm)
  508.     local chan='xtensionxtooltip2'
  509.     local id,name=GetChannelName(chan)
  510.     local data={}
  511.     local itr=0
  512.     if event=='CHAT_MSG_CHANNEL' and string.find(cnName, chan) then
  513.         local dash=string.find(snd, '-')
  514.         local send=''
  515.         if dash~=nil then
  516.             send=string.sub(snd, 1, dash-1)
  517.         else
  518.             send=snd
  519.         end
  520.         for word in string.gmatch(msg, '%S+') do
  521.             itr=itr+1
  522.             data[itr]=word
  523.         end
  524.         if data[1]=='RlPl' then
  525.             if data[4]==plyr then
  526.                 if data[3]=='atk' then
  527.                     if accepting_combat==true then
  528.                         if able_combat==true then
  529.                             RlPl_roll(data[2], 'dfd', send)
  530.                         else
  531.                             prnt(send..' ruthlessly presses their attack.', colors.Strength)
  532.                         end
  533.                     else
  534.                         -- prnt('You fend off an attack')
  535.                     end
  536.                 elseif data[3]=='dfd' then
  537.                     if pending[send]~=nil then
  538.                         local diff=pending[send]-data[5]
  539.                         SendChatMessage('RlPl bcast '..send..' '..diff.. ' '..data[2], 'CHANNEL', nil, id)
  540.                     end
  541.                 end
  542.             elseif data[2]=='bcast' then
  543.                 local distan=CheckInteractDistance(send, 4)
  544.                 if distan==true then --1 = inspect, 4 = follow
  545.                     local diff=tonumber(data[4])
  546.                     if diff>0 then
  547.                         wld='beaten'; iject=' by a margin of ('..math.abs(diff)..')'
  548.                     elseif diff<0 then
  549.                         wld='lost to'; iject=' by a margin of ('..math.abs(diff)..')'
  550.                     else
  551.                         wld='come to a draw with'; iject=''
  552.                     end
  553.                     local result=send..' has '..wld..' '..data[3]..iject..' in a contest of '..cats[data[5]]..'!' -- send is always the attacker, announcing results of their own fight
  554.                     local loss=false
  555.                     if data[3]==plyr and wld=='beaten' then loss=true end
  556.                     if send==plyr and wld=='lost to' then loss=true end
  557.                     if loss==true then
  558.                         PlaySoundFile(wound[hh])
  559.                         ffrm(.5, .5, 2, colors[cats[data[5]]], .5, nil, 5, nil)
  560.                         Rllply.health=Rllply.health-1
  561.                         hbar(Rllply.health)
  562.                         if Rllply.health==0 then
  563.                             prnt('You\'ve been utterly defeated... for now.', colors.Wisdom)
  564.                             --loss sequence
  565.                         end
  566.                     end
  567.                     prnt(result, colors[cats[data[5]]])
  568.                 end
  569.             end
  570.         end
  571.     end
  572. end
  573.  
  574. if not roll_listener then
  575.     roll_listener=CreateFrame('Frame', nil, mPane)
  576.     roll_listener:RegisterEvent('CHAT_MSG_CHANNEL')
  577.     roll_listener:SetScript('OnEvent', multyPlecksR)
  578. end
  579.  
  580. local function resetStats()
  581.     for k,v in pairs(Rllply) do
  582.         Rllply[k]=rlpl_stats[k];
  583.     end
  584.     for k,v in pairs(cats) do
  585.         UIShow[k].amt:SetText(Rllply[k])
  586.     end
  587.     incFrRply:Show()
  588.     tbar(Rllply.train)
  589. end
  590.  
  591. local function resetHealth()
  592.     local function fillup()
  593.         hbar(10)
  594.         able_combat=true
  595.         PlaySoundFile('Sound\\Spells\\SPELL_MK_ENVELOPINGMISTS_HEAL.OGG')
  596.         ffrm(.5, .5, 2, colors.reset, .5, nil, 5, nil)
  597.         prnt('You feel much better', colors.reset)
  598.     end
  599.     if faction=='Horde' then
  600.         if dist(spirits[1], spirits[2])<.003 then
  601.             fillup()
  602.         else
  603.             ffrm(.3, .3, 1, colors.Dexterity, .5, nil, 5, nil)
  604.             prnt('You must find Sijambi in the Valley of Spirits for rejuvenation!', colors.warn)
  605.         end
  606.     else --Alliance
  607.         if dist(cathedral[1], cathedral[2])<.006 then
  608.         -- if 2>1 then
  609.             fillup()
  610.         else
  611.             ffrm(.3, .3, 1, colors.Dexterity, .5, nil, 5, nil)
  612.             prnt('You must go to the altar in the Cathedral of Stormwind for rejuvenation!', colors.warn)
  613.         end
  614.     end
  615. end
  616.  
  617. function trainTggl()
  618.     if train_state=='off' then
  619.         mPane:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  620.         prnt('Training mode!  Whack a dummy.  A wooden one.', colors.Charisma)
  621.         resetS:SetNormalTexture("Interface\\COMMON\\Indicator-Green")
  622.         train_state='on'
  623.     elseif train_state=='on' then
  624.         mPane:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  625.         prnt('You relax from training.', colors.Charisma)
  626.         resetS:SetNormalTexture("Interface\\COMMON\\Indicator-Yellow")
  627.         train_state='off'
  628.     end
  629. end
  630.  
  631. resetS:SetScript('OnClick', function()
  632.     if Rllply.train>=rlpl_stats.train and train_state=='off' then
  633.         prnt('You have already trained enough', colors.warn)
  634.     else
  635.         trainTggl()
  636.     end
  637. end)
  638. resetH:SetScript('OnClick', function()
  639.     resetHealth()
  640. end)
  641.  
  642. prnt('Bailey bids you welcome, traveler.', colors.white)
  643.  
  644. end --RlPl_layout
  645.  
  646.  
  647. function mPaneOnEvent(table_val, event, addon, ...)
  648.     if event=='ADDON_LOADED' and addon=='RollPlay' then
  649.         if Rllply==nil then Rllply={} end
  650.         for k,v in pairs(rlpl_stats) do
  651.             if Rllply[k]==nil or dev_mode==true then
  652.                 Rllply[k]=v
  653.             end
  654.         end
  655.         RlPl_layout()
  656.     elseif event=='PLAYER_LOGOUT' and addon=='RollPlay' then
  657.     elseif event=='COMBAT_LOG_EVENT_UNFILTERED' then
  658.         local spell, maybe_isEnemy, plyGUID, playName, maybe_spellID, who_knows, tarGUI, tarName, xx, yy, zz= ...
  659.         if playName~=nil and playName==plyr then
  660.             if tarName~=nil then
  661.                 if string.find(tarName, 'ummy') then
  662.                     if spell=='SPELL_CAST_SUCCESS' or spell=='SWING_DAMAGE' then
  663.                         if Rllply.train<rlpl_stats.train then
  664.                             Rllply.train=Rllply.train+1
  665.                             tbar(Rllply.train)
  666.                             if Rllply.train==rlpl_stats.train then
  667.                                 -- resetStats()
  668.                                 --rewriting resetStats for scoping here
  669.                                 for k,v in pairs(Rllply) do
  670.                                     Rllply[k]=rlpl_stats[k];
  671.                                 end
  672.                                 for k,v in pairs(cats) do
  673.                                     UIShow[k].amt:SetText(Rllply[k])
  674.                                 end
  675.                                 incFrRply:Show() -- xyzzy
  676.                                 tbar(Rllply.train)
  677.                                 --end resetStats
  678.                                 ffrm(.3, .3, 1, colors.Charisma, .5, nil, 5, nil)
  679.                                 prnt('Excellent work, you\'re in peak form.', colors.Charisma)
  680.                                 trainTggl()
  681.                             end
  682.                         else
  683.                             prnt('Already max trained!'); mPane:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  684.                         end
  685.                         -- print(spell, maybe_isEnemy, plyGUID, playName, maybe_spellID, who_knows, tarGUI, tarName, xx, yy, zz)
  686.                     end
  687.                 end
  688.             end
  689.         end
  690.     end
  691. end
  692.  
  693. mPane:SetScript('OnEvent', mPaneOnEvent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement