WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   BCC: Any good way to tell if a mount can fly? (https://www.wowinterface.com/forums/showthread.php?t=58862)

fullmoon_sulfuras 07-29-21 07:26 PM

BCC: Any good way to tell if a mount can fly?
 
Hi! I'm trying to figure out if a mount, say, the Great While Kodo (ID 18793), can fly. I know it can't, but is there an API function that could tell me if a mount can fly? The best I could come up with is to exhaustively check for the name of the flying mounts:

string.find(mount.name, "Windrider")

- Griffon
- Windrider
- Cenarion War Hippogryph (33999)
- Netherwing Drake
- Nether Ray
- Ashes of Al'ar (32458)
- Flying Machine

This is for BCC.

Thanks!

Ekaterina 07-29-21 09:30 PM

Code:

creatureDisplayInfoID, description, source, isSelfMount, mountTypeID,
uiModelSceneID, animID, spellVisualKitID, disablePlayerMountPreview
  = C_MountJournal.GetMountInfoExtraByID(mountID)
  = C_MountJournal.GetDisplayedMountInfoExtra(index)

https://wowpedia.fandom.com/wiki/API...tInfoExtraByID

One of the returns is the mountTypeId with for flying should be 248 for most flying mounts.

fullmoon_sulfuras 07-30-21 07:44 AM

Is C_MountJournal available in BCC?

SDPhantom 07-30-21 06:12 PM

It isn't available in BCC. You'll have to build your own database for item and/or spell IDs depending on if you're checking inventory or buffs.

Fizzlemizz 07-30-21 06:41 PM

It might be better to watch the 2.5.2 PTR and how it progresses.

SDPhantom 07-31-21 03:31 AM

Quote:

Originally Posted by Fizzlemizz (Post 339635)
It might be better to watch the 2.5.2 PTR and how it progresses.

They're not going to make major system changes like this to the client in the middle of an expansion.
Especially when there was no precedent for it in the reference content. Mount Journal didn't exist until WoD.

fullmoon_sulfuras 07-31-21 09:09 AM

I came up with the following function:

Lua Code:
  1. function Lunar.Items:BCCIsFlyingMount(mount)
  2.     local items = { "Windrider", "Gryphon", "Cenarion War Hippogryph", "Netherwing Drake", "Nether Ray", "Ashes of Al'ar", "Flying Machine" }
  3.  
  4.     for _,v in pairs(items) do
  5.         if string.find(mount, v) then
  6.             return true
  7.         end
  8.     end
  9.     return false
  10. end

Where mount is the item's name.

Zax 08-01-21 12:55 PM

tContains do the same thing:

Lua Code:
  1. function Lunar.Items:BCCIsFlyingMount(mount)
  2.     local items = { "Windrider", "Gryphon", "Cenarion War Hippogryph", "Netherwing Drake", "Nether Ray", "Ashes of Al'ar", "Flying Machine" }
  3.         return tContains(items, mount)
  4. end

SDPhantom 08-04-21 12:26 AM

tContains() doesn't run string pattern matching.
Also, it's better to compare by itemID rather than name, otherwise localization will be a problem.

Zax 08-04-21 09:53 AM

Quote:

Originally Posted by SDPhantom (Post 339659)
tContains() doesn't run string pattern matching.

Unless I missed something, after testing with tContains, Lunar.Items:BCCIsFlyingMount("Gryphon") returns true.
Quote:

Originally Posted by SDPhantom (Post 339659)
Also, it's better to compare by itemID rather than name, otherwise localization will be a problem.

Right.

SDPhantom 08-04-21 04:38 PM

There is no mount simply named "Gryphon". For example, if you tried to match with Ebon Gryphon, tContains() will return false while the manual search returns true because tContains() (using tIndexOf()) doesn't do pattern matching. This is what string.find() is doing.

Zax 08-04-21 11:32 PM

OK, I understand.
Thank you for your explanation SDPhantom.

fullmoon_sulfuras 08-06-21 06:01 PM

Quote:

Originally Posted by SDPhantom (Post 339659)
tContains() doesn't run string pattern matching.
Also, it's better to compare by itemID rather than name, otherwise localization will be a problem.

That's a great point, I'll switch to a (longer) list of item IDs.

Thanks!!


All times are GMT -6. The time now is 07:13 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI