View Single Post
12-31-23, 05:45 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
I heard it sing only today. Maybe the time between songs is just longer randoms.

If you (and just you) wanted to hear it more often you could use something like:
The min/max times can be set to whatever doesn't annoy you (8, 12 seconds is very short but you don't have to wait long to test.)

Lua Code:
  1. -- More music for Sunflower pet
  2. local minTime, maxTime = 8, 12 -- min/max times between songs in seconds
  3. local castID = 93823
  4. local guids = { -- add additional guids here
  5.     ["BattlePet-0-0000121FED47"] = true,
  6.     ["BattlePet-0-0000121FED42"] = true,
  7. }
  8. local soundIDs = {
  9.     567354,
  10.     567327,
  11.     567317,
  12.     567338,
  13.     567374,
  14.     567295,
  15. }
  16. local summoned
  17. local function SingFlowerSing()
  18.     local id = C_PetJournal.GetSummonedPetGUID()
  19.     if not guids[id] then
  20.         summoned = false
  21.         return
  22.     end
  23.     PlaySoundFile(soundIDs[random(1, #soundIDs)])      
  24.     C_Timer.After(random(minTime, maxTime), SingFlowerSing)
  25. end
  26. local f = CreateFrame("Frame")
  27. f:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player")
  28. f:RegisterUnitEvent("UNIT_LEVEL", "player")
  29. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  30. f:SetScript("OnEvent", function(self, event, ...)
  31.     local unit, _, spellid = ...
  32.     if event == "UNIT_SPELLCAST_SUCCEEDED" and spellid == castID then
  33.         if not summoned then
  34.             summoned = true
  35.             C_Timer.After(random(minTime, maxTime), SingFlowerSing)
  36.         end
  37.     elseif event == "PLAYER_ENTERING_WORLD" or event == "UNIT_LEVEL" then
  38.         local id = C_PetJournal.GetSummonedPetGUID()
  39.         if guids[id] then
  40.             self:GetScript("OnEvent")(self, "UNIT_SPELLCAST_SUCCEEDED", "player", nil, castID)
  41.             self:UnregisterEvent("UNIT_LEVEL")
  42.         end
  43.         self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  44.         if event == "UNIT_LEVEL" then
  45.             self:UnregisterEvent("UNIT_LEVEL")
  46.         end
  47.     end
  48. end)
Copy/paste the code to the website addon.bool.no to create download as an addon.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-31-23 at 10:32 PM.
  Reply With Quote