[3.3.5a][Eluna][TrinityCore]How to edit player phasemask on accepting a quest menu

User Tag List

Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    DewmGuy's Avatar Member
    Reputation
    1
    Join Date
    Sep 2023
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    Do you want to share your full script and the output of Eluna please?
    Code:
    local NPCgryan = 234 -- gryan stoutmantle
    local NPCtraitor = 467 -- defias traitor
    local QUESTmessenger = 142 -- messenger quest
    local QUESTtraitor = 155 -- escort quest
    
    local function onSpawnTraitor(event, creature)
        creature:SetPhaseMask(2)
    end
    
    local function QuestGiverEvents(event, player, pUnit, quest, _) 
        if quest:GetId() == QUESTmessenger then
            if event == 31 then -- player accepts quest 142
                player:SetPhaseMask(3) -- traitor npc becomes visible
            end
        end
        if quest:GetId() == QUESTtraitor then
            if event == 34 then  -- player completes quest 155
                player:SetPhaseMask(1) -- traitor npc becomes invisible
            end
        end
    end
    
    local function PLAYER_EVENT_ON_QUEST_ABANDON(event, player, questId)
        if questId == QUESTmessenger then
            player:SetPhaseMask(1) -- traitor npc becomes invisible
        end
    end
    
    RegisterCreatureEvent(NPCtraitor, 5, onSpawnTraitor) -- spawn
    RegisterCreatureEvent(NPCgryan, 31, QuestGiverEvents) -- accept
    RegisterCreatureEvent(NPCgryan, 34, QuestGiverEvents) -- reward
    RegisterPlayerEvent(38, PLAYER_EVENT_ON_QUEST_ABANDON) -- abandon
    
    --CREATURE_EVENT_ON_QUEST_ACCEPT = 31  -- // (event, player, creature, quest) - Can return true
    --CREATURE_EVENT_ON_QUEST_REWARD = 34  -- // (event, player, creature, quest, opt) - Can return true
    i realized i deleted my script in frustration so i rewrote it, it's basically the same. the npc is correctly phased but when you start quest 155 the escort script doesn't start. Also, i'm not sure how to handle the player logging out and back in if they have the quest. i'm not sure that changing the player's phase is the best option for this scenario but changing the npc phase would affect every player in the zone.
    Last edited by DewmGuy; 09-15-2023 at 02:01 AM.

    [3.3.5a][Eluna][TrinityCore]How to edit player phasemask on accepting a quest
  2. #17
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DewmGuy View Post
    Code:
    local NPCgryan = 234 -- gryan stoutmantle
    local NPCtraitor = 467 -- defias traitor
    local QUESTmessenger = 142 -- messenger quest
    local QUESTtraitor = 155 -- escort quest
    
    local function onSpawnTraitor(event, creature)
        creature:SetPhaseMask(2)
    end
    
    local function QuestGiverEvents(event, player, pUnit, quest, _) 
        if quest:GetId() == QUESTmessenger then
            if event == 31 then -- player accepts quest 142
                player:SetPhaseMask(3) -- traitor npc becomes visible
            end
        end
        if quest:GetId() == QUESTtraitor then
            if event == 34 then  -- player completes quest 155
                player:SetPhaseMask(1) -- traitor npc becomes invisible
            end
        end
    end
    
    local function PLAYER_EVENT_ON_QUEST_ABANDON(event, player, questId)
        if questId == QUESTmessenger then
            player:SetPhaseMask(1) -- traitor npc becomes invisible
        end
    end
    
    RegisterCreatureEvent(NPCtraitor, 5, onSpawnTraitor) -- spawn
    RegisterCreatureEvent(NPCgryan, 31, QuestGiverEvents) -- accept
    RegisterCreatureEvent(NPCgryan, 34, QuestGiverEvents) -- reward
    RegisterPlayerEvent(38, PLAYER_EVENT_ON_QUEST_ABANDON) -- abandon
    
    --CREATURE_EVENT_ON_QUEST_ACCEPT = 31  -- // (event, player, creature, quest) - Can return true
    --CREATURE_EVENT_ON_QUEST_REWARD = 34  -- // (event, player, creature, quest, opt) - Can return true
    i realized i deleted my script in frustration so i rewrote it, it's basically the same. the npc is correctly phased but when you start quest 155 the escort script doesn't start. Also, i'm not sure how to handle the player logging out and back in if they have the quest. i'm not sure that changing the player's phase is the best option for this scenario but changing the npc phase would affect every player in the zone.

    What about something like this?
    Code:
    
    local NPC = {
        gryan = 234, -- gryan stoutmantle
        traitor = 467, -- defias traitor
    }
    local QUEST = {
        messenger = 142, -- messenger quest
        traitor = 155, -- escort quest
    }
    
    local function onSpawnTraitor(event, creature)
        creature:SetPhaseMask(2) -- this should probably be set in the DB instead of on spawn
    end
    
    local function QuestGiverEvents(event, player, pUnit, quest, _) 
        local questId = quest:GetId()
    
        pUnit:SendUnitSay("You have accepted quest " .. tostring(questId) .. ", event: " .. tostring(event)) -- Debug, can delete
    
        if event == 31 and questId == QUEST.messenger then -- quest accept
            player:SetPhaseMask(3) -- traitor npc becomes visible
        elseif event == 34 and questId == QUEST.traitor then -- quest reward
            player:SetPhaseMask(1) -- traitor npc becomes invisible
        end
    end
    
    local function PLAYER_EVENT_ON_QUEST_ABANDON(event, player, questId)
        if questId == QUEST.messenger then
    
            player:SendBroadcastMessage("Abandoning quest!") -- Debug, can delete
    
            player:SetPhaseMask(1) -- traitor npc becomes invisible
        end
    end
    
    local function PLAYER_EVENT_ON_LOGIN(event, player)
        for _,questId in pairs(QUEST) do
            if player:HasQuest(questId) then
    
                player:SendBroadcastMessage("Updating phase on login!") -- Debug, can delete
    
                player:SetPhaseMask(3) -- traitor npc becomes visible
                break
            end
        end
    end
    
    RegisterCreatureEvent(NPC.traitor, 5, onSpawnTraitor) -- spawn
    RegisterCreatureEvent(NPC.gryan, 31, QuestGiverEvents) -- accept
    RegisterCreatureEvent(NPC.gryan, 34, QuestGiverEvents) -- reward
    RegisterPlayerEvent(38, PLAYER_EVENT_ON_QUEST_ABANDON) -- abandon
    RegisterPlayerEvent(3, PLAYER_EVENT_ON_LOGIN)
    
    --CREATURE_EVENT_ON_QUEST_ACCEPT = 31  -- // (event, player, creature, quest) - Can return true
    --CREATURE_EVENT_ON_QUEST_REWARD = 34  -- // (event, player, creature, quest, opt) - Can return true
    But really you want a zone update. When they enter/exit the area of your quest you update the phase.

    Maybe something like this would work fow you:
    Code:
    PLAYER_EVENT_ON_UPDATE_ZONE             =     27,       // (event, player, newZone, newArea)
    Global:RegisterPlayerEvent - Eluna

  3. #18
    DewmGuy's Avatar Member
    Reputation
    1
    Join Date
    Sep 2023
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so just a recap:

    a) it looks like you just put the variables into arrays to simplify and to allow for looping

    b) the only thing you added was the PLAYER_EVENT_ON_LOGIN function

    c) you think PLAYER_EVENT_ON_UPDATE_ZONE would be a better solution than on login?

    Code:
    local function PLAYER_EVENT_ON_UPDATE_ZONE(event, player, newZone, newArea)
        if newZone == {westfall} and player:HasQuest(QUEST.messenger) then
            print("player entered westfall")
            player:SetPhaseMask(3)
            print("player phase changed to 3")
        else
            player:SetPhaseMask(1)
        end
    end
    
    RegisterPlayerEvent(27,  PLAYER_EVENT_ON_UPDATE_ZONE)
    Last edited by DewmGuy; 09-16-2023 at 01:19 AM.

  4. #19
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DewmGuy View Post
    so just a recap:

    a) it looks like you just put the variables into arrays to simplify and to allow for looping

    b) the only thing you added was the PLAYER_EVENT_ON_LOGIN function

    c) you think PLAYER_EVENT_ON_UPDATE_ZONE would be a better solution than on login?

    Code:
    local function PLAYER_EVENT_ON_UPDATE_ZONE(event, player, newZone, newArea)
        if newZone == {westfall} and player:HasQuest(QUEST.messenger) then
            print("player entered westfall")
            player:SetPhaseMask(3)
            print("player phase changed to 3")
        else
            player:SetPhaseMask(1)
        end
    end
    
    RegisterPlayerEvent(27,  PLAYER_EVENT_ON_UPDATE_ZONE)
    I added a lot of debug messages so you can see where it is not working as you want.

    Zone update may be required as well as on login. Only one may be required. One to test out.

    Your else condition there probably wants to check if the current zone is your phase 3 area, so you don't phase to 1 on zone change always everywhere.

  5. #20
    DewmGuy's Avatar Member
    Reputation
    1
    Join Date
    Sep 2023
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    I added a lot of debug messages so you can see where it is not working as you want.

    Zone update may be required as well as on login. Only one may be required. One to test out.

    Your else condition there probably wants to check if the current zone is your phase 3 area, so you don't phase to 1 on zone change always everywhere.
    I have been using the print function to debug because I prefer to monitor the server console. But this still only outputs %s when an error in the script occurs. The way you phrased your language earlier made it sound like the compiler would output a formatted error like PHP or JavaScript, giving me a code or output to identify what's wrong with the code. It's fine that that isn't the case. It's inconvenient that I must add so many print lines to my code to investigate it when something isn't working as intended.

    Does a zone update not occur at the same time a login event occurs? I assumed that a zone update would occur during the login process. Using the on login function would set my phase to 3 even if I'm in Stormwind, which is not ideal.

    Does the number 27 represent westfall here? Or is that an event code representing login? The closest code I could find from Trinitycore resources was that the zone ID for Westfall is 40. Could you weigh in on that?

    Code:
    local function PLAYER_EVENT_ON_UPDATE_ZONE(event, player, newZone, newArea)
        if newZone == 27 and player:HasQuest(QUEST.messenger) then
            player:SetPhaseMask(3)
        elseif newZone == 27
            player:SetPhaseMask(1)
        end
    end
    
    RegisterPlayerEvent(27, PLAYER_EVENT_ON_UPDATE_ZONE)

  6. #21
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DewmGuy View Post
    I have been using the print function to debug because I prefer to monitor the server console. But this still only outputs %s when an error in the script occurs. The way you phrased your language earlier made it sound like the compiler would output a formatted error like PHP or JavaScript, giving me a code or output to identify what's wrong with the code. It's fine that that isn't the case. It's inconvenient that I must add so many print lines to my code to investigate it when something isn't working as intended.

    Does a zone update not occur at the same time a login event occurs? I assumed that a zone update would occur during the login process. Using the on login function would set my phase to 3 even if I'm in Stormwind, which is not ideal.

    Does the number 27 represent westfall here? Or is that an event code representing login? The closest code I could find from Trinitycore resources was that the zone ID for Westfall is 40. Could you weigh in on that?

    Code:
    local function PLAYER_EVENT_ON_UPDATE_ZONE(event, player, newZone, newArea)
        if newZone == 27 and player:HasQuest(QUEST.messenger) then
            player:SetPhaseMask(3)
        elseif newZone == 27
            player:SetPhaseMask(1)
        end
    end
    
    RegisterPlayerEvent(27, PLAYER_EVENT_ON_UPDATE_ZONE)
    I don't know how you would only see %s as your script output. Without showing the code you are using, I have no way to help. Stop making assumptions, some things do not work intuitively. Have you tried with the broadcast messages? What is the output?

    If you have a syntax error then yes, the compiler will output an error message. But if your code is just bad logic then you will not get an error, and because you cannot attach a debugger since it's an interpreted language, you have to output instead. This is the same for PHP, JS, Lua, and all interpreted languages.

    27 is the event ID. Look at the doc: Global:RegisterPlayerEvent - Eluna

  7. #22
    DewmGuy's Avatar Member
    Reputation
    1
    Join Date
    Sep 2023
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    I don't know how you would only see %s as your script output. Without showing the code you are using, I have no way to help. Stop making assumptions, some things do not work intuitively. Have you tried with the broadcast messages? What is the output?

    If you have a syntax error then yes, the compiler will output an error message. But if your code is just bad logic then you will not get an error, and because you cannot attach a debugger since it's an interpreted language, you have to output instead. This is the same for PHP, JS, Lua, and all interpreted languages.

    27 is the event ID. Look at the doc: Global:RegisterPlayerEvent - Eluna
    Hey Harry,

    It's been a few months since I had time to look at this concept. I've written a couple of other scripts based on the work of other script developers. I also reread our thread and there's some interesting ideas in here and I'd like to utilize them to reach a solution that I can employ for a variety of quests. Ultimately, I would want to create a bunch of scenarios for phasing based on the concepts brought into WOTLK that will make changes to the world as the player progresses through the quests. Are you interested in helping me kind of start over with this approach and develop a reliable "framework" that I can use to extrapolate this idea out to other quests? Or maybe you know of a script that already exists that is in line with what i'm looking to achieve.

    If you're willing to consult and provide advice, I'd like to start with developing phasing concepts in westfall based around the defias brotherhood questline. I think if I can get a solid grasp of how phasing works more generally, and how to apply phasing properties to creatures and objects, then I can take this concept and apply it to other quests and circumstances to help with world building elements in the server.

    For example: The Defias Brotherhood - Quest - WotLK Classic

    This part of the chain is where the defias messenger NPC needs to be sought and killed. Ideally, he would not appear to the player until the prerequisite quests in the chain have been completed, The Defias Brotherhood - Quest - WotLK Classic is the step prior.

    Some considerations to consider would include quest abandonment, zone, map, and whether a player is in a party with another player who has not done the quests. I'm sure there are more. Anyway, let me know if this is something you'd like to help with. Other ideas that I have in related quest lines would include reducing the number of NPCs that appear after each step of the people's militia quest line, like, fewer looters and pillagers, etc.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. How to edit bosses HP and change loot settings
    By murdock666 in forum World of Warcraft Guides
    Replies: 13
    Last Post: 09-08-2016, 07:49 AM
  2. [Question] How to edit your title on live servers?
    By Galadius in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 05-09-2009, 05:04 AM
  3. <inser belt name> .blp, how to edit it properly?
    By Diclonius in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 04-29-2007, 06:14 PM
  4. REQUEST- Someone tell me how to Edit models on a mac version!
    By karlov in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 03-07-2007, 05:21 PM
  5. How to edit your WoW Models
    By Cush in forum World of Warcraft Model Editing
    Replies: 27
    Last Post: 02-27-2007, 07:31 PM
All times are GMT -5. The time now is 06:52 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search