SmartMount

118 - Filter profession-specific mounts

Since options are stored per-character, may as well make use of LibMounts' GetProfessionRestriction() function to filter out profession-specific mounts that the character can't use when building the available mounts list. They'd generally just be disabled by the player anyway and this allows SmartMount to "automagically" avoid trying to summon a mount that's unusable by that character.

Code snippet below (@ line 265):

		-- count the mounts I have	
		local mounts = self:CountMounts(true, false, true)
		for i, _ in pairs(mounts) do
				for _, v in pairs(mounts[i]) do
					local _, itemName, itemSpellID, itemTexture, _ = GetCompanionInfo("MOUNT", v.slot)
					if type(itemName) ~= 'string' then
						self:dump('mounts['..i..']', v)
						self:dump('itemName', itemName)
						self:dump('itemTexture', itemTexture)
					else
					local CanUseByProf = LibStub("LibMounts-1.0"):GetProfessionRestriction(itemSpellID)
						if CanUseByProf then
						-- update cache
							self:GetPref('ListOfMountsCache')[v.action] = (-i)..':'..itemName
						--self:SetTablePref('ListOfMountsCache', v.action, i..':'..itemName)
						-- set list
							self.ListOfMounts[v.action] = {
								type = 'MOUNT',
								action = v.action,
								name = itemName,
								slot = v.slot,
								can = true,
	-- Mount Indexes!! 1 = very slow, 2 = travel/ghost wolf, 3 = ground, 4 = aq, 5 = vashj, 6 = fly, 7 = fly+ground 
								mount = i,
								land = (i <= 4) or (i == 7),
								fly = (i == 6) or (i == 7),
								swim = false,
								incombat = false,
								inwater = true,
								inair = false,
								onground = true,
								inhouse = false,
								icon = itemTexture,
							}
						end -- if
					end -- if
				end -- for
		end -- for


The GetProfessionRestriction() call will always return True for non-profession mounts, so those are covered. As mentioned above, this addition will skip adding mounts that cannot be used due to profession restriction to the table of available mounts thus eliminating the need to manually add them to the exclusions list on characters that do not posses the skill.

User When Change
WyzrdX Jun 04, 2013 at 02:43 UTC
WyzrdX Jun 04, 2013 at 02:43 UTC Changed assigned to from akazik to WyzrdX
Daeymien Jun 03, 2013 at 12:01 UTC Changed description type from Markdown to BBCode

Changed description:
  Since options are stored per-character, may as well make use of LibMounts' GetProfessionRestriction() function to filter out profession-specific mounts that the character can't use when building the available mounts list. They'd generally just be disabled by the player anyway and this allows SmartMount to "automagically" avoid trying to summon a mount that's unusable by that character.

  Code snippet below (@ line 265):
-
+ [code]
  		-- count the mounts I have
  		local mounts = self:CountMounts(true, false, true)
  		for i, _ in pairs(mounts) do
----------------------------------------
  					end -- if
  				end -- for
  		end -- for
-
+ [/code]
  The GetProfessionRestriction() call will always return True for non-profession mounts, so those are covered. As mentioned above, this addition will skip adding mounts that cannot be used due to profession restriction to the table of available mounts thus eliminating the need to manually add them to the exclusions list on characters that do not posses the skill.
Daeymien Jun 03, 2013 at 12:00 UTC Changed description type from Plain Text to Markdown

Changed description:
  Since options are stored per-character, may as well make use of LibMounts' GetProfessionRestriction() function to filter out profession-specific mounts that the character can't use when building the available mounts list. They'd generally just be disabled by the player anyway and this allows SmartMount to "automagically" avoid trying to summon a mount that's unusable by that character.

- It's just a matter of inserting 2 lines into SmartMount.lua (at line 268) under the "-- count the mounts I have" section. Code snippet below:
+ Code snippet below (@ line 265):
+
+ 		-- count the mounts I have
  		local mounts = self:CountMounts(true, false, true)
  		for i, _ in pairs(mounts) do
- 			local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("MOUNT", i)
+ 				for _, v in pairs(mounts[i]) do
+ 					local _, itemName, itemSpellID, itemTexture, _ = GetCompanionInfo("MOUNT", v.slot)
+ 					if type(itemName) ~= 'string' then
+ 						self:dump('mounts['..i..']', v)
+ 						self:dump('itemName', itemName)
+ 						self:dump('itemTexture', itemTexture)
+ 					else
- 			if LibStub("LibMounts-1.0"):GetProfessionRestriction(creatureSpellID) then
+ 					local CanUseByProf = LibStub("LibMounts-1.0"):GetProfessionRestriction(itemSpellID)
- ...
+ 						if CanUseByProf then
+ 						-- update cache
+ 							self:GetPref('ListOfMountsCache')[v.action] = (-i)..':'..itemName
+ 						--self:SetTablePref('ListOfMountsCache', v.action, i..':'..itemName)
+ 						-- set list
+ 							self.ListOfMounts[v.action] = {
+ 								type = 'MOUNT',
+ 								action = v.action,
+ 								name = itemName,
+ 								slot = v.slot,
+ 								can = true,
+ 	-- Mount Indexes!! 1 = very slow, 2 = travel/ghost wolf, 3 = ground, 4 = aq, 5 = vashj, 6 = fly, 7 = fly+ground
+ 								mount = i,
+ 								land = (i <= 4) or (i == 7),
+ 								fly = (i == 6) or (i == 7),
+ 								swim = false,
+ 								incombat = false,
+ 								inwater = true,
+ 								inair = false,
+ 								onground = true,
+ 								inhouse = false,
+ 								icon = itemTexture,
+ 							}
+ 						end -- if
  					end -- if
  				end -- for
- 			end -- then
  		end -- for

  The GetProfessionRestriction() call will always return True for non-profession mounts, so those are covered. As mentioned above, this addition will skip adding mounts that cannot be used due to profession restriction to the table of available mounts thus eliminating the need to manually add them to the exclusions list on characters that do not posses the skill.
Daeymien Jun 03, 2013 at 10:32 UTC Changed description:
  Since options are stored per-character, may as well make use of LibMounts' GetProfessionRestriction() function to filter out profession-specific mounts that the character can't use when building the available mounts list. They'd generally just be disabled by the player anyway and this allows SmartMount to "automagically" avoid trying to summon a mount that's unusable by that character.

- It's just a matter of inserting 2 lines into SmartMount.lua (don't have the exact line number ATM) under the "-- count the mounts I have" section. Code snippet below:
+ It's just a matter of inserting 2 lines into SmartMount.lua (at line 268) under the "-- count the mounts I have" section. Code snippet below:
-
+ 		local mounts = self:CountMounts(true, false, true)
+ 		for i, _ in pairs(mounts) do
  			local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("MOUNT", i)
  			if LibStub("LibMounts-1.0"):GetProfessionRestriction(creatureSpellID) then
  ...
Daeymien Jun 03, 2013 at 10:27 UTC
Daeymien Nov 26, 2012 at 22:50 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 3 comments
  • Avatar of WyzrdX WyzrdX Jun 04, 2013 at 02:42 UTC - 0 likes

    @Daeymien: Go

    Daeymien

    I recently became involved in the project and while I understand you would like this feature added, I am currently working on sorting out the functions so I can begin moving away from LibRock as it has been deprecated.

    My intentions are to rely on Ace3, and as soon as I finish removing and rewriting the code to rely on Ace and have a working project I will post a notice on the front page.

    I have been using SmartMount for years and I personally am grateful that akazik has allowed me to work on this. Smartmount has been good, better than some of the others but once LibRock is no more I feel it will be so much better.

    So please be patient with me as I make the changes and when I have something working, I will get the users involved for testing and suggestions.

    WyzrdX

  • Avatar of Daeymien Daeymien Jun 03, 2013 at 12:00 UTC - 0 likes

    EDIT 2: Added entire code block (shouldn't try to remember where stuff goes at 3am with no sleep)

  • Avatar of Daeymien Daeymien Jun 03, 2013 at 10:27 UTC - 0 likes

    EDIT: Updating with actual code since this ticket hasn't seen any activity since 2012

  • 3 comments

Facts

Last updated
Jun 04, 2013
Reported
Nov 26, 2012
Status
Accepted - Problem reproduced / Need acknowledged.
Type
Patch - Source code patch for review
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees