Multiplayer Quests

Qdden

New Member
Reaction score
1
I'm making a multiplayer rpg map were the players are able to receive quests. But in the "Quest - create"-action you can not choose for what player to create the quest for.
Can you make only one player receive the quest or must you have all the quests created from start and then enable them for players via variables?
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
You could have a condition in the trigger that lets the player receive the quest that says

Code:
(Triggering unit) belongs to (Player X)

X would the player number of the player that you want to receive the quest.

I hope this helps :D
 

darkbeer

Beer is Good!
Reaction score
84
i'm not sure that this works and im too lazy to try out myself, but what about using GetLocalPlayer() ?

Example:
Code:
Events - Unit enters rect blabla
Actions - CustomScript: if GetOwningPlayer(GetTriggerUnit()) == GetLocalPlayer() then
Create your Quest  ....
CustomScript: endif

i hop that works, care for desyncs, since im not sure if GetLocalPlayer() is ok with quests^^
 

Qdden

New Member
Reaction score
1
I actually found this thread http://www.thehelper.net/forums/showthread.php?t=39489 . I think it will help Thank you both anyway.
You could have a condition in the trigger that lets the player receive the quest that says

Code:
Code:
(Triggering unit) belongs to (Player X)
X would the player number of the player that you want to receive the quest.

And i don't understand how this would work since i still cant apply the quest to only one player?
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
Well, since that is a condition in the trigger that lets you get the quest, only Player X would be able to receive it. It's fairly simple, I think. :p
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
The key is JASS.

Just follow this small little tutorial:

GetLocalPlayer() will perform an action for only ONE player. This is very handy, but it is an extreme desync function. You CANNOT create or destroy a handle. By doing so, you create a risk of a desync that automatically crashes Warcraft.

So, to do this; you can hide/show quests for players. If the quest isn't enabled, it won't appear. So that is what we must do.

So, use this code:
JASS:
    call QuestSetEnabled(QUEST,false)
    if GetLocalPlayer() == Player(0) then
        call QuestSetEnabled(QUEST,true)
    endif


In GUI, I don't know what it is. So I'll explain it.

QuestSetEnabled: Enables/disables the quest. We'll disable the quest for all players by doing so.
- QUEST: This is important, put in your quest here. If you do not know what to put, create a global variable called QUEST exactly like that. Then use the code below..
- False - DO NOT edit this. This will disable the quest.​

GetLocalPlayer() This function will allow you to do something for one player.
- Player(0) - This is the player and its number. Put either 0 (P1 Red) or all the way up to 11 (P12 Brown). So, Player(5) will actually be (Player 6 (Orange))​

QUEST: This is important, put in your quest here. If you do not know what to put, create a global variable called QUEST exactly like that. Then use the code below..


So basically, just do this if you made a quest variable called QUEST:
Code:
    set QUEST = (Last Created Quest)
    Custom Script:    call QuestSetEnabled(udg_QUEST,false)
    Custom Script:    if GetLocalPlayer() == Player(0) then
    Custom Script:    call QuestSetEnabled(udg_QUEST,true)
    Custom Script:    endif

This will show the quest only for one player.

To do this for other players and quests, edit only what's UNDERLINED in the explanation... So the two quest areas and the player.

Sorry if you can't understand this. It is practically the only way to easily enable it for one player.
 

Qdden

New Member
Reaction score
1
I guess i will need one quest variable per quest.
Well i understood the code as follows:
Code:
set QUEST = (Last Created Quest)              
Custom Script:    call QuestSetEnabled(udg_QUEST,false) <- Set last created quest to not enabled.
Custom Script:    if GetLocalPlayer() == Player(0) then <- Local player means triggering player?
Custom Script:    call QuestSetEnabled(udg_QUEST,true) <- what is udg_quest?
Custom Script:    endif

Thank you for the nice reply even though i'm not 100% on what it all means ;)
+rep and even more if someone help me with this aswel :D

Edit: also, should i put all of this in the quest creation trigger.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Local player means triggering player?

No, it means the player that is currently running the trigger.
Triggers runs on all computers in the game, not just one.


> what is udg_quest?

Global variables created from the variable editor need "udg_" in front of them if used in JASS.


> should I put all of this in the quest creation trigger?

Maybe.
Depends on when you want to do it.

You could create all quests for all players at map init, and disable them all.
Then enable as players discover them.
 

Qdden

New Member
Reaction score
1
Great explanation thank you. But if i create allot of quests and disable them. then are they shown as Undiscovered in the quest log. If they are not shown, then i actually taught about the answer before creating the topic :S
 

Qdden

New Member
Reaction score
1
I have given every quest a separate variable array. Could I enable these quests by using the GetLocalPlayer() variable to only enable them for one player? If that is possible how could that piece of code look like?
 

Qdden

New Member
Reaction score
1
Alright ;)

I have a Int trigger that looks like this:
Code:
Events:
     Map initialization...
Actions:
     For each (integer A)from 1 to 10 do:
          Create quest titled blabla with description blabla icon blabla
          Set GazloweQuest1[(integer A)] = (Last crated quest)
          Disable (Last created quest)
          ---- Separating comment ----
          Create quest titled blabla with description blabla icon blabla
          Set GazloweQuest2[(integer A)] = (Last crated quest)
          Disable (Last created quest)
          and so on for quests with the variables GazloweQuest3 and FarmQuest1
When the quest is being enabled it looks like this:
Code:
Event: Player - selects a unit
Action: Quest enable GazloweQuest1[(Player number of (Triggering player))]
What i didn't think about this trigger were that i still had the problem that i never assigned a player to each quest =P what it does is just creating allot of quest variables :S

The essential
The variables i have right now are:
GazloweQuest1
GazloweQuest2
GazloweQuest3
FarmQuest1
But i guess it will be an repeatable trigger since i think i will add more quests later on.
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
In fact, try this:
JASS:
function EnableQuestForPlayer takes quest q, player p returns nothing
        call QuestSetEnabled(q,false)
    if GetLocalPlayer() == p then
        call QuestSetEnabled(q,true)
    endif
endfunction


Put it in the map header (go to the trigger editor, click the map name, then add it to the function box area to the right.

Now, you can call it like this:
Code:
    custom script: call EnableQuestForPlayer(udg_GazloweQuest1, Player(0))

That will enable the gazlowequest1 for player 1.

In the following codes, I will enable the quests for player 1 (red). Edit the number in the parentheses after the word "Player" to change who it will show to..

Gazlowe Quest 1:
Code:
    Custom script: call EnableQuestForPlayer(udg_GazloweQuest1, Player(0))
Gazlowe Quest 2:
Code:
    Custom script: call EnableQuestForPlayer(udg_GazloweQuest2, Player(0))
Gazlowe Quest 3:
Code:
    Custom script: call EnableQuestForPlayer(udg_GazloweQuest3, Player(0))
Farm Quest 1:
Code:
    Custom script: call EnableQuestForPlayer(udg_FarmQuest1, Player(0))

Just put these scripts after your variables and such for the quest.

I hope this helps. :)

Post any further questions here, and then PM me. I will hopefully have time to answer it. :)
 

Qdden

New Member
Reaction score
1
Seems to be working :D
Instead of a specific player can i put triggering player , owner of triggering unit etc?
Is there a list for there commands somewhere?

Also i want the same thing but when i disable the quests during game play for only one person i made this trigger:
Code:
function DisableQuestForPlayer takes quest q, player p returns nothing
        call QuestSetDisabled(q,false)
    if GetLocalPlayer() == p then
        call QuestSetDisabled(q,true)
    endif
endfunction
and
Code:
call DisableQuestForPlayer( udg_GazloweQuest1 , Player(0) )
but it says:
Expected a function name for call QuestSetDisabled(q,false) i may be doing it all wrong ;)
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
Yeah, QuestSetDisabled isn't a function, the "false" area determines whether or not it is enabled or disabled. So if the QuestSetEnabled boolean parameter is "True", the quest will be enabled. If it reads "false" it will disable it.

So, yeah.

@Pyrogasm:

That's what I did :p
Purgeandfire said:
JASS:
function EnableQuestForPlayer takes quest q, player p returns nothing
        call QuestSetEnabled(q,false)
    if GetLocalPlayer() == p then
        call QuestSetEnabled(q,true)
    endif
endfunction
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
Oh, I see: he just copied it wrong. I thought you had written Disabled :p
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
Seems to be working :D
Instead of a specific player can i put triggering player , owner of triggering unit etc?
Is there a list for there commands somewhere?

Also i want the same thing but when i disable the quests during game play for only one person i made this trigger:
Code:
function DisableQuestForPlayer takes quest q, player p returns nothing
        call QuestSetDisabled(q,false)
    if GetLocalPlayer() == p then
        call QuestSetDisabled(q,true)
    endif
endfunction
and
Code:
call DisableQuestForPlayer( udg_GazloweQuest1 , Player(0) )
but it says:
Expected a function name for call QuestSetDisabled(q,false) i may be doing it all wrong ;)

Sorry, I didn't read your post.

Yes, you can use triggering player instead of a specific one. To find a list of commands, open the world editor, then make a function using the desired player. So, make a function that uses "Triggering Player".

Go to "Edit > Convert to Custom Text" to view it in JASS. Copy and paste the triggering player value and replace the "Player(#)" part for all areas..

Also, QuestSetDisabled doesn't exist. Instead, you must invert the boolean values:

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


Do you want the quest enabled for all players, or just that particular player?

For the particular player, just use the code above like this:
JASS:
    Custom Script:    call DisableQuestForPlayer(udg_QUEST,p)
 

Qdden

New Member
Reaction score
1
Thank you very much for the replys. But it seems like the quest disapears from the one having it when someone takes it. Must the quest variable be an array?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top