• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How do you show Quest for single player?

Status
Not open for further replies.
Level 8
Joined
Jul 17, 2004
Messages
283
There are 3 players in my game. I'm trying to make it so each player has their own quest record.

So what I need help with is... How do you show a quest to only a single player? And how do you show the TalkToMe (exclamation point) special effect to only a single player, and then remove it for a single player as well?

Edit: In more simpler terms... I want to locally show a special effect (exclamation point) above a Quest Giver when a quest is available to that specific player, and destroy the special effect when there is no quest available, all at different times, across 3 different players.
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Both quests and effects are agent types, which count to the common id pool. So localizing those objects for good is dangerous. You can however, use the QuestSetEnabled function on single clients or for effects differentiate the used model.

JASS:
function DisplayQuestToPlayer takes quest q, player p returns nothing
    if (GetLocalPlayer() == p) then
        call QuestSetEnabled(q, true)
    endif
endfunction

JASS:
function CreateEffectForPlayer takes string path, real x, real y, player p returns effect
    if (GetLocalPlayer() != p) then
        set path = ""
    endif

    return AddSpecialEffect(path, x, y)
endfunction

GetLocalPlayer() is an async function, it returns different values for different clients. So you can use that to execute blocks of code for single players.
 
Level 8
Joined
Jul 17, 2004
Messages
283
Alright, so this is what I did. Please tell me if this will work out and won't cause desyncing.

I ran this at map ini to create an exclamation point sfx above the quest giver for all players:

  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set TalkToMe_Enabled = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
    • Set TalkToMe_Disabled = <Empty String>
    • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
      • Loop - Actions
        • -------- Note: GetEnumPlayer() is Picked Player. --------
        • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
        • Set TalkToMe = TalkToMe_Enabled
        • Custom script: endif
        • Special Effect - Create a special effect attached to the overhead of Farmer John 0002 <gen> using TalkToMe
        • Set SFX[(Player number of (Picked player))] = (Last created special effect)
And then once a player talks to the quest giver with their hero, I run this to destroy the exclamation point sfx for only that player:

  • Special Effect - Destroy SFX[(Player number of (Player))]
And then once a new quest becomes available, I run this to re-create an exclamation point sfx for that player:

  • Set TalkToMe = TalkToMe_Disabled
  • Custom script: if GetLocalPlayer() == udg_Player then
  • Set TalkToMe = TalkToMe_Enabled
  • Custom script: endif
  • Special Effect - Create a special effect attached to the overhead of Farmer John 0002 <gen> using TalkToMe
  • Set SFX[(Player number of (Player))] = (Last created special effect)
 
Level 8
Joined
Jul 17, 2004
Messages
283
Got it. Thank you :) +Rep

  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set TalkToMe_Enabled = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
    • Set TalkToMe_Disabled = <Empty String>
    • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
      • Loop - Actions
        • Set TalkToMe = TalkToMe_Disabled
        • -------- Note: GetEnumPlayer() is Picked Player. --------
        • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
        • Set TalkToMe = TalkToMe_Enabled
        • Custom script: endif
        • Special Effect - Create a special effect attached to the overhead of Farmer John 0002 <gen> using TalkToMe
        • Set SFX[(Player number of (Picked player))] = (Last created special effect)
 
Status
Not open for further replies.
Top