mpstark / DynamicCam

A more dynamic camera for World of Warcraft.
MIT License
23 stars 11 forks source link

FEATURE REQUESTS: Joining a group, Targeting an enemy NPC, and doing a World Quest #122

Open ZaViper opened 4 days ago

ZaViper commented 4 days ago

Hello! Will it be possible to create three additional situations?

  1. When joining a group.
  2. When targeting an enemy NPC.
  3. When on a world quest.

I have attempted to create custom situations for theses using these events:

But the situations don't get triggered. Am I doing something wrong, or does situations like these needs to be added to the addon?

LudiusMaximus commented 4 days ago

Hello, the event is just to determine the time at which the conditions for all situations get checked. You have to write a condition that returns true whenever your situation should be active. Think of a situation as a state not as an event. From the top of my head, I do not know how to achieve what you have in mind.

  1. Could be "while in a group". This could be checked with https://warcraft.wiki.gg/wiki/API_UnitInParty
  2. Could be "while an enemy NPC is targeted". This could be checked similar to the NPC interaction.
  3. "While on a world quest". I am not sure.
ZaViper commented 3 days ago

Thank you for pointing me in the right direction! I ended up using ChatGPT to help write some custom code that worked perfectly for the conditions I needed. I thought I’d share them here in case anyone else finds this post and wants to create their own, or if you’d like to consider adding these as default profiles.

1.) For when you’re in a group:

return UnitInParty("player") or UnitInRaid("player")

2.) When targeting a hostile NPC:

return UnitIsEnemy("player", "target") and not UnitIsDead("target") and UnitCanAttack("player", "target")

3.) For World Quests (when you’re in an area with an active World Quest):

return C_QuestLog.GetNumQuestLogEntries() > 0 and (function()
    for i = 1, C_QuestLog.GetNumQuestLogEntries() do
        local questInfo = C_QuestLog.GetInfo(i)
        if questInfo and QuestUtils_IsQuestWorldQuest(questInfo.questID) and C_QuestLog.IsOnQuest(questInfo.questID) then
            return true
        end
    end
    return false
end)()

To give some context for how I use these:

I hope this helps anyone else with similar needs!