Thread Tools Display Modes
01-09-15, 09:38 AM   #1
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
How can I tell when the player enters their garrison?

In a nutshell, I want to know either when the player enters the garrison, or whether the player is inside the garrison at a given moment.
Is there any way to do this that doesn't require comparing the actual zone name (which requires checking for Alliance/ Horde, as well as translations(?
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
01-09-15, 10:18 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Lua Code:
  1. local garrisonMaps = {
  2.     [1152] = true, -- FW Horde Garrison Level 1
  3.     [1330] = true, -- FW Horde Garrison Level 2
  4.     [1153] = true, -- FW Horde Garrison Level 3
  5.     [1154] = true, -- FW Horde Garrison Level 4
  6.     [1158] = true, -- SMV Alliance Garrison Level 1
  7.     [1331] = true, -- SMV Alliance Garrison Level 2
  8.     [1159] = true, -- SMV Alliance Garrison Level 3
  9.     [1160] = true, -- SMV Alliance Garrison Level 4
  10. }
  11.  
  12. local function InGarrison()
  13.     local name, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
  14.     if(garrisonMaps[instanceMapID]) then
  15.         return true
  16.     end
  17.     return false
  18. end
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
01-09-15, 12:43 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
Can't you just do this instead of the if...then block?
Code:
return garrisonMaps[instanceMapID]
If you really needed to typecast into boolean, then this would work.
Code:
return garrisonMaps[instanceMapID] and true or false
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
01-09-15, 01:27 PM   #4
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
Code:
return garrisonMaps[instanceMapID] or false
  Reply With Quote
01-09-15, 02:54 PM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
C_Garrison.IsOnGarrisonMap() returns whether they're currently in a garrison, and I believe C_Garrison.IsUsingPartyGarrison() can be checked against to see if they're in their own.
  Reply With Quote
01-09-15, 03:37 PM   #6
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Originally Posted by semlar View Post
C_Garrison.IsOnGarrisonMap() returns whether they're currently in a garrison, and I believe C_Garrison.IsUsingPartyGarrison() can be checked against to see if they're in their own.
Damnit, I went over all the garrison functions and somehow managed to miss that one... thanks
(The GetInstanceInfo solution was working well though!)

[Edit]
Oh, right, I did actually find that function, but saw that it kept returning true even when I was outside my garrison so I moved on... it's odd, but it does change to false if I move far enough.
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!

Last edited by Malsomnus : 01-09-15 at 03:40 PM.
  Reply With Quote
01-09-15, 06:23 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
There is a radius around your actual garrison walls that is still part of your garrison "property" and part of the garrison instance.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-09-15, 06:40 PM   #8
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I also think the radius of the actual zone is different than that of the phased area. Maybe the different functions pertains to those two different areas.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-10-15, 07:01 AM   #9
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I would assume one of the zone events would fire when you enter a Garrison? Meaning there is no specific or special zone event fired? That would be my guess, and then check the above mentioned Garrison APIs.

*Edit: What I am curious to find out is if you are inside a specific Garrison building, and how you would find that out. For example, are you inside the Mine, or Barracks, etc.

Last edited by myrroddin : 01-10-15 at 07:03 AM. Reason: Subzone within a subzone?
  Reply With Quote
01-10-15, 10:23 AM   #10
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
The minimap text changes when you enter a building so it should be trivial.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-10-15, 11:30 AM   #11
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Lombra View Post
The minimap text changes when you enter a building so it should be trivial.
Apologies, I was not clear. Using ZONE_CHANGED_INDOORS and GetSubZoneText() will work up until a point. But if you need to do an if/then check, since the result of GetSubZoneText() is localized, and AddOns cannot as far as I know get subzoneIDs, that becomes very difficult. You can't check for GetSubZoneText()=="Cleft of Shadows" on a non-English client. By the same token, you can't use that method to check if the player is in the Garrison mine, castle, herb garden, etc.

Besides that if/then check being very difficult, how can we tell which Garrison building is in which plot, since each player can put any large building onto any large plot, medium building on any medium plot, etc. Or even if a plot is unused.

Must we still depend on LibBabble-SubZones-3.0?
  Reply With Quote
01-10-15, 12:06 PM   #12
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Originally Posted by myrroddin View Post
Apologies, I was not clear. Using ZONE_CHANGED_INDOORS and GetSubZoneText() will work up until a point. But if you need to do an if/then check, since the result of GetSubZoneText() is localized, and AddOns cannot as far as I know get subzoneIDs, that becomes very difficult. You can't check for GetSubZoneText()=="Cleft of Shadows" on a non-English client. By the same token, you can't use that method to check if the player is in the Garrison mine, castle, herb garden, etc.

Besides that if/then check being very difficult, how can we tell which Garrison building is in which plot, since each player can put any large building onto any large plot, medium building on any medium plot, etc. Or even if a plot is unused.

Must we still depend on LibBabble-SubZones-3.0?
Well, it might not be trivial, but it's totally possible. Instead of comparing the subzone name to e.g. "Cleft of Shadows", you compare it to the localized version of that string.
As for the plot number, you can obtain it through the Garrison API though it's a bit annoying. What do you need this for, anyway?
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
01-10-15, 02:21 PM   #13
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Assuming the subzone of the building has the same name as it does on the garrison map, you could loop over the plots to create a table with the localized name as the key and the building id as the value.

That would give you something to cross reference the minimap text with for a language-independent number.

Check C_Garrison.GetBuildings() and C_Garrison.GetBuildingInfo(buildingID)

Last edited by semlar : 01-10-15 at 02:23 PM.
  Reply With Quote
01-10-15, 05:36 PM   #14
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
http://www.wowinterface.com/forums/s...light=garrison

https://docs.google.com/spreadsheets...it?pli=1#gid=0
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-10-15, 10:42 PM   #15
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Malsomnus View Post
What do you need this for, anyway?
A pet project, that is a LibStub version of Astrolabe. I'm not in any rush, but forward-thinking about marking maps with icons, when the map is a subzone. For example, micro-dungeons or the Garrison mine.

Yes, I realize the nodes in the mine and herb garden are random; one thing at a time!
  Reply With Quote
01-23-15, 02:50 PM   #16
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
Originally Posted by semlar View Post
Check C_Garrison.GetBuildings() and C_Garrison.GetBuildingInfo(buildingID)
I think this should work well, though I'll need to do some testing. GetBuildings includes a texture name ("GarrBuilding_Min_1_A") which I think will be the same for everyone. It also gives the building ID which you can pass to GetBuildingInfo to get the (hopefully) locale-correct name which you can use to compare to the SubZone text.

I checked on 2 Alliance characters, one with a Level 3 Mine and one with a Level 2. buildingIDs were different, but plotID (59) and texPrefix(see above) were the same. WoWHead shows the Mines being building ID(61-62) regardless of faction.
  Reply With Quote
01-23-15, 02:55 PM   #17
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
I checked an Alliance guy who did not have a Mine yet and /dump C_Garrison.GetBuildingInfo(61) still returned "Lunarfall Excavation" for the name. I tried a Horde who didn't have a Garrison yet and it returned the same name, which isn't right. I don't (yet) have a Horde with a Garrison so I'm not sure what it would return then.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How can I tell when the player enters their garrison?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off