Detecting World PvP Zones
Someone has recently commented on my KillingBlow_Enhanced AddOn that it doesn't work in Ashran when PvP only mode (i.e. only report killing blows when in PvP zones) is enabled. To detect if the current zone is a PvP zone, I'm calling IsInInstance and checking if the instance type (second return value) is "pvp" or "arena".
Is there an easy way to detect whether the current zone is a World PvP zone? The World Battlefield API section didn't have any obvious solution to this. |
Thanks, I'll use that approach.
|
I try to avoid to use SetMapToCurrentZone() as much as I can (so far I could totally avoid it) because it will interfere with the user watching another map. The alternative approach that works well is to use GetInstanceInfo()
Code:
local _,_,_,_,_,_,_,zone = GetInstanceInfo() |
That's a good idea. Using GetInstanceInfo, I can at least avoid calling SetMapToCurrentZone on every continent except Northrend.
|
Just for future reference:
When you enter a new continent/instance (including when you first log in), PLAYER_ENTERING_WORLD and ZONE_CHANGED_NEW_AREA are fired in that order. When PLAYER_ENTERING_WORLD fires, GetInstanceInfo returns the correct instance map ID but GetCurrentMapAreaID returns the area ID of the continent. When ZONE_CHANGED_NEW_AREA fires, GetCurrentMapAreaID returns the correct area ID (after you call SetMapToCurrentZone). |
Quote:
http://wowprogramming.com/docs/api/GetWorldPVPAreaInfo |
Presumably you can just use IsInActiveWorldPVP()
There's also GetZonePVPInfo() |
I do something like this in "remgank" :
Lua Code:
It seems to work for me ... |
Quote:
Lua Code:
|
Quote:
This would also set the map to the wrong zone if you're currently inside of a microdungeon. There are other things to consider when changing the map, like how extremely cpu intensive addons like Routes and Gatherer would react. The only safeish method for actively changing the current map is to unregister WORLD_MAP_UPDATE from every frame that's watching it, do your thing and swap the map back to what it previously was, then re-register the event to those frames. I don't recommend anyone do that unless they fully comprehend how the map works. |
Quote:
The default UI only seems to call it when you right click on a unit on the world map to determine whether or not you can report them as AFK. WoW Programming doesn't have any documentation for it and Wowpedia doesn't have it listed at all. |
I really don't know how Ashran works but from what I could test:
1) IsInActiveWorldPVP() always return false 2) You can't be there for long if you are not accepted to the battle, you will be teleported out 3) When you are accepted BATTLEFIELD_MGR_ENTERED triggers 4) When you leave Ashran BATTLEFIELD_MGR_EJECTED triggers 5) You are not put into an instance group like Tol Barad and Wintergrasp In Tol Barad (and Wintergrasp) 1) IsInActiveWorldPVP() return true if in the area of an active battle even if you didn't accept the invite 2) You can't be there for long if you are not accepted to the battle, you will be teleported out 3) When you are accepted BATTLEFIELD_MGR_ENTERED triggers 4) When you leave battle area BATTLEFIELD_MGR_EJECTED triggers (but I am still in Tol Barad Peninsula). 5) Tol Barad and Tol Barad Peninsula shares the same GetInstanceInfo() returns 6) When the battle finishes BATTLEFIELD_MGR_STATE_CHANGED triggered 7) Only when I left the instance group or moved out of the Tol Barad battle area (and entering in Tol Barad Peninsula) was that BATTLEFIELD_MGR_EJECTED triggered. BATTLEFIELD_MGR_ENTERED BATTLEFIELD_MGR_EJECTED BATTLEFIELD_MGR_STATE_CHANGE arg1 is the battleID: 21 Tol Barad, 24 Ashran, 1 for Wintergrasp. |
Quote:
|
This is working perfectly in all three places (Ashran, Tol Barad and Wintergrasp):
Lua Code:
|
Ashran doesn't appear to be considered world pvp by IsInActiveWorldPVP() but GetZonePVPInfo() returns "combat" for the type and "true" for the second argument (which is incorrectly documented as meaning FFA and I'm not entirely sure what it means).
Depending on your definition of active pvp, I think something like this should work. Lua Code:
|
Semlar, Choonsters asked for events as well, because even if your function works there is still the problem when to call it. I tested my solution so unless someone points any flaw on it, I would say the problem is solved.
|
Quote:
The events to watch are ZONE_CHANGED_NEW_AREA for traveling between major zones, potentially ZONE_CHANGED for subzones, PLAYER_ENTERING_WORLD specifically for catching reloaded UIs (because zone information is not accurate between other loading screens), and if those events don't occur when starting a battle like wintergrasp then include the BATTLEFIELD_MGR events. You're also missing brackets in your BATTLEFIELD_MGR_STATE_CHANGE condition, so it probably isn't going to behave like you're expecting. |
Quote:
|
Thanks for all the responses. I already have arenas and BGs working, but I hadn't actually considered FFA PvP zones (I never did much PvP myself); I was only thinking of the three World PvP zones (Ashran, Tol Barad and Wintergrasp). That said, I think PvP only mode should cover all types of PvP zone like Semlar said.
Unless someone finds a flaw in it, I'll probably go with Semlar's solution (GetZonePVPInfo/IsInActiveWorldPVP) and check it at zone change events (PLAYER_ENTERING_WORLD, ZONE_CHANGED and ZONE_CHANGED_NEW_AREA) and World PvP events (BATTLEFIELD_MGR_*). Does any event fire when entering or exiting the floor of the Gurubashi Arena (i.e. the FFA zone)? It looks like the subzone covers the whole arena and the surrounding area, so ZONE_CHANGED may not be useful. Edit: Just realised I can probably test this myself on a trial account. I'll probably do it tomorrow. |
Just went to Gurubashi Arena and ZONE_CHANGED triggers when you enter or leave the circular center area (the arena). In some points if you are very close to the edge you can cross the zone without going to the ground level but I don't think that is relevant.
UNIT_FACTION also triggers but when you leave the center area you still keep the FFA status for a while. Maybe you can use UnitIsPVPFreeForAll("player") when UNIT_FACTION triggers (arg1 being "player"), to check if you are or not in a FFA combat. That would avoid you to use ZONE_CHANGED. I still prefer my solution (for world pvp) because BATTLEFIELD_MGR_* triggers only rarely and most of times will be relevant for your problem. For battlegrounds and arenas all you need to do is call IsInInstance() when PLAYER_ENTERING_WORLD triggers (I know you are already doing that). So apparently is totally possible to avoid using ZONE_CHANGED and ZONE_CHANGED_NEW_AREA. Here my complete solution attempt: Lua Code:
|
All times are GMT -6. The time now is 01:04 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI