In short:
This "system" allows you to create a list of quests, assign it different difficulties and let players get quests for the difficulties they wish.
I made it for a guy in this thread, and just wanted to know what you others think about it.
I can say that it's a bit experimential, but I have tested it a lot and there's no bugs or leaks as far as I know. It should be very easy to create your own random quest list.
How it works in game:
Player 1 can type "new" to start a new quest. You can only do this if you have less than 4 active quests. A multiboard appears in which you choose the difficulty of the quest, and after that, you activate a random quest from the list you have made, and its description
appears. As soon as you have killed all the units you're supposed to kill, a "Completed Quest"-message appears and you get the reward. You can type "questlist" to get a list of your current
quests.
To make your own quests, you only have to set a few variables at map start. This is how I have done with quest 1 (you can see it in the Quest Variables trigger in my demo map):
Set QuestName[1] = |cff00dd00Pure Epic Slaughtering|r
Set QuestMessage[1] = There's something special about killing humans, right? I would really like you to kill 5 of them.
Set QuestTarget[1] = Footman
Set QuestKills[1] = 5
Set QuestRewardGold[1] = 200
So, when you activate the quest, you will see this message:
Pure Epic Slaughtering (green text)
There's something special about killing humans, right? I would really like you to kill 5 of them.
And when you have killed 5 footmen, you get 200 gold. You can set these values to anything, it works perfectly. Also, you can set this:
Set QuestRewardLumber[1] = 200
Set QuestRewardItem[1] = Snow Shoes
...to add lumber and item rewards. The item appears at the body of the last unit you killed for the quest.
Also, you can add
Set QuestCompletedMessage[1] = "Your mother will be proud!"
...to make that message appear when the quest is completed, instead of the ordinary "You have completed the quest"-message.
So, this was quest one, and obviously, every quest has a number. When you choose an easy quest, you get one random from quest 1 to 10. Medium quests are 11 to 25, and hard are
from 26 to 50. This can be easily changed (if you, for example want 20 easy quests, from 1 to 20), you can see where in the Choose New Quest trigger. However, DO NOT use quest 0.
Just because you're not supposed to, and because I say so.
If you want to change the maximum number of active quests, there's just a few 4's you have to change in the code. I have marked them with comments.
However, the objective of the quest doesn't have to be killing creatures. If so, just set quest's QuestKills to 1, and QuestTarget to an unique unit which you place in a special area in the
map so that it cannot be reached, seen, or killed. Then you add in quest message what the players should do, trigger your quest in the way you want, and when it's goals has been met, just
make the unit who completed the quest, damage that special unit via some Damage Unit action or DamageUnit function.
OK, I will forget to write some thing anyway. Ask if you need, so I can continue. To import this system, add these triggers to your map:
Kill Quest Units
Choose New Quests
New Quest Dialog
... and create these global variables:
QuestTaken Boolean Array
QuestDialog Dialog Array
DialogButton Dialog Button Array
KillCount Integer Array
QuestId Integer Array
QuestKills Integer Array
QuestRewardGold Integer Array
QuestRewardLumber Integer Array
QuestRewardItem Item Array
QuestCompletedMessage String Array
QuestMessage String Array
QuestName String Array
QuestTarget Unit-Type Array
This "system" allows you to create a list of quests, assign it different difficulties and let players get quests for the difficulties they wish.
I made it for a guy in this thread, and just wanted to know what you others think about it.
I can say that it's a bit experimential, but I have tested it a lot and there's no bugs or leaks as far as I know. It should be very easy to create your own random quest list.
How it works in game:
Player 1 can type "new" to start a new quest. You can only do this if you have less than 4 active quests. A multiboard appears in which you choose the difficulty of the quest, and after that, you activate a random quest from the list you have made, and its description
appears. As soon as you have killed all the units you're supposed to kill, a "Completed Quest"-message appears and you get the reward. You can type "questlist" to get a list of your current
quests.
To make your own quests, you only have to set a few variables at map start. This is how I have done with quest 1 (you can see it in the Quest Variables trigger in my demo map):
Set QuestName[1] = |cff00dd00Pure Epic Slaughtering|r
Set QuestMessage[1] = There's something special about killing humans, right? I would really like you to kill 5 of them.
Set QuestTarget[1] = Footman
Set QuestKills[1] = 5
Set QuestRewardGold[1] = 200
So, when you activate the quest, you will see this message:
Pure Epic Slaughtering (green text)
There's something special about killing humans, right? I would really like you to kill 5 of them.
And when you have killed 5 footmen, you get 200 gold. You can set these values to anything, it works perfectly. Also, you can set this:
Set QuestRewardLumber[1] = 200
Set QuestRewardItem[1] = Snow Shoes
...to add lumber and item rewards. The item appears at the body of the last unit you killed for the quest.
Also, you can add
Set QuestCompletedMessage[1] = "Your mother will be proud!"
...to make that message appear when the quest is completed, instead of the ordinary "You have completed the quest"-message.
So, this was quest one, and obviously, every quest has a number. When you choose an easy quest, you get one random from quest 1 to 10. Medium quests are 11 to 25, and hard are
from 26 to 50. This can be easily changed (if you, for example want 20 easy quests, from 1 to 20), you can see where in the Choose New Quest trigger. However, DO NOT use quest 0.
Just because you're not supposed to, and because I say so.
If you want to change the maximum number of active quests, there's just a few 4's you have to change in the code. I have marked them with comments.
However, the objective of the quest doesn't have to be killing creatures. If so, just set quest's QuestKills to 1, and QuestTarget to an unique unit which you place in a special area in the
map so that it cannot be reached, seen, or killed. Then you add in quest message what the players should do, trigger your quest in the way you want, and when it's goals has been met, just
make the unit who completed the quest, damage that special unit via some Damage Unit action or DamageUnit function.
OK, I will forget to write some thing anyway. Ask if you need, so I can continue. To import this system, add these triggers to your map:
Kill Quest Units
function Trig_Kill_Quest_Units_Actions takes nothing returns nothing
local integer i = 1
local location l = null
local integer id
loop
if GetUnitTypeId(GetDyingUnit()) == udg_QuestTarget[udg_QuestId] then
set id = udg_QuestId
set udg_KillCount = udg_KillCount + 1
if udg_KillCount == udg_QuestKills[id] then
set l = GetUnitLoc(GetDyingUnit())
if udg_QuestCompletedMessage[id] == null then
call DisplayTextToForce(GetPlayersAll(),"You have completed the quest "+udg_QuestName[id]+" and recieved "+ I2S(udg_QuestRewardGold[id])+" gold!")
else
call DisplayTextToForce(GetPlayersAll(),udg_QuestCompletedMessage[udg_QuestId[id]])
endif
call SetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_GOLD) + udg_QuestRewardGold[id])
call SetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_LUMBER,GetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_LUMBER) + udg_QuestRewardLumber[id])
call CreateItemLoc(GetItemTypeId(udg_QuestRewardItem),l)
call RemoveLocation(l)
set udg_QuestTaken[udg_QuestId] = false
set udg_QuestId = 0
set udg_KillCount = 0
else
call DisplayTextToForce(GetPlayersAll()),"You have killed "+I2S(udg_KillCount)+"/"+I2S(udg_QuestKills[id])+" "+GetUnitName(GetDyingUnit())+"s.")
endif
endif
exitwhen i > 4
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Kill_Quest_Units takes nothing returns nothing
set gg_trg_Kill_Quest_Units = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Kill_Quest_Units, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Kill_Quest_Units, function Trig_Kill_Quest_Units_Actions )
endfunction
local integer i = 1
local location l = null
local integer id
loop
if GetUnitTypeId(GetDyingUnit()) == udg_QuestTarget[udg_QuestId] then
set id = udg_QuestId
set udg_KillCount = udg_KillCount + 1
if udg_KillCount == udg_QuestKills[id] then
set l = GetUnitLoc(GetDyingUnit())
if udg_QuestCompletedMessage[id] == null then
call DisplayTextToForce(GetPlayersAll(),"You have completed the quest "+udg_QuestName[id]+" and recieved "+ I2S(udg_QuestRewardGold[id])+" gold!")
else
call DisplayTextToForce(GetPlayersAll(),udg_QuestCompletedMessage[udg_QuestId[id]])
endif
call SetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_GOLD) + udg_QuestRewardGold[id])
call SetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_LUMBER,GetPlayerState(GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_LUMBER) + udg_QuestRewardLumber[id])
call CreateItemLoc(GetItemTypeId(udg_QuestRewardItem),l)
call RemoveLocation(l)
set udg_QuestTaken[udg_QuestId] = false
set udg_QuestId = 0
set udg_KillCount = 0
else
call DisplayTextToForce(GetPlayersAll()),"You have killed "+I2S(udg_KillCount)+"/"+I2S(udg_QuestKills[id])+" "+GetUnitName(GetDyingUnit())+"s.")
endif
endif
exitwhen i > 4
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Kill_Quest_Units takes nothing returns nothing
set gg_trg_Kill_Quest_Units = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Kill_Quest_Units, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Kill_Quest_Units, function Trig_Kill_Quest_Units_Actions )
endfunction
Choose New Quests
function Trig_Choose_New_Quest_Actions takes nothing returns nothing
local integer id = 0
local integer slot = 1
local integer s = 0
if GetClickedButton() == udg_DialogButton[0] then
loop
// Quest 1 to 10 are Easy. Change the values below to change that.
set id = GetRandomInt(1,10)
exitwhen udg_QuestTaken[id] == false and id != 0
endloop
loop
exitwhen udg_QuestId[slot] == 0
set slot = slot + 1
endloop
elseif GetClickedButton() == udg_DialogButton[1] then
loop
// Quest 11 to 25 are Medium. Change the values below to change that.
set id = GetRandomInt(11,25)
exitwhen udg_QuestTaken[id] == false
endloop
loop
exitwhen udg_QuestId[slot] == 0
set slot = slot + 1
endloop
elseif GetClickedButton() == udg_DialogButton[2] then
loop
// Quest 26 to 50 are Hard. Change the values below to change that.
set id = GetRandomInt(26,50)
exitwhen udg_QuestTaken[id] == false
endloop
loop
exitwhen udg_QuestId[slot] == 0
set slot = slot + 1
endloop
endif
loop
call DisplayTextToForce(GetPlayersAll()),udg_QuestName[id])
call DisplayTextToForce(GetPlayersAll()),udg_QuestMessage[id])
set s = s +1
exitwhen s == 11
endloop
set udg_QuestId[slot] = id
set udg_QuestTaken[id] = true
endfunction
//===========================================================================
function InitTrig_Choose_New_Quest takes nothing returns nothing
set gg_trg_Choose_New_Quest = CreateTrigger( )
call TriggerRegisterDialogEventBJ( gg_trg_Choose_New_Quest, udg_QuestDialog[0] )
call TriggerAddAction( gg_trg_Choose_New_Quest, function Trig_Choose_New_Quest_Actions )
endfunction
local integer id = 0
local integer slot = 1
local integer s = 0
if GetClickedButton() == udg_DialogButton[0] then
loop
// Quest 1 to 10 are Easy. Change the values below to change that.
set id = GetRandomInt(1,10)
exitwhen udg_QuestTaken[id] == false and id != 0
endloop
loop
exitwhen udg_QuestId[slot] == 0
set slot = slot + 1
endloop
elseif GetClickedButton() == udg_DialogButton[1] then
loop
// Quest 11 to 25 are Medium. Change the values below to change that.
set id = GetRandomInt(11,25)
exitwhen udg_QuestTaken[id] == false
endloop
loop
exitwhen udg_QuestId[slot] == 0
set slot = slot + 1
endloop
elseif GetClickedButton() == udg_DialogButton[2] then
loop
// Quest 26 to 50 are Hard. Change the values below to change that.
set id = GetRandomInt(26,50)
exitwhen udg_QuestTaken[id] == false
endloop
loop
exitwhen udg_QuestId[slot] == 0
set slot = slot + 1
endloop
endif
loop
call DisplayTextToForce(GetPlayersAll()),udg_QuestName[id])
call DisplayTextToForce(GetPlayersAll()),udg_QuestMessage[id])
set s = s +1
exitwhen s == 11
endloop
set udg_QuestId[slot] = id
set udg_QuestTaken[id] = true
endfunction
//===========================================================================
function InitTrig_Choose_New_Quest takes nothing returns nothing
set gg_trg_Choose_New_Quest = CreateTrigger( )
call TriggerRegisterDialogEventBJ( gg_trg_Choose_New_Quest, udg_QuestDialog[0] )
call TriggerAddAction( gg_trg_Choose_New_Quest, function Trig_Choose_New_Quest_Actions )
endfunction
New Quest Dialog
function Trig_New_Quest_Button_Conditions takes nothing returns boolean
local integer i = 1
loop
//this is one of the 4's you have to change if you want to change the max number of active quests.
if i > 4 then
return false
exitwhen true
elseif udg_QuestId == 0 then
return true
exitwhen true
endif
set i = i + 1
endloop
if GetPlayerId(GetTriggerPlayer()) != 0 then
return false
endif
return true
endfunction
function Trig_New_Quest_Button_Actions takes nothing returns nothing
call DialogClear(udg_QuestDialog[0])
call DialogSetMessage( udg_QuestDialog[0], "Choose new quest difficulty" )
set udg_DialogButton[0] = DialogAddButton( udg_QuestDialog[0], "Easy",1 )
set udg_DialogButton[1] = DialogAddButton( udg_QuestDialog[0], "Medium",2 )
set udg_DialogButton[2] = DialogAddButton( udg_QuestDialog[0], "Hard",3 )
call DialogDisplay(Player(0),udg_QuestDialog[0],true)
endfunction
//===========================================================================
function InitTrig_New_Quest_Dialog takes nothing returns nothing
set gg_trg_New_Quest_Dialog = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_New_Quest_Dialog, Player(0), "new", true )
call TriggerAddCondition( gg_trg_New_Quest_Dialog, Condition( function Trig_New_Quest_Button_Conditions ) )
call TriggerAddAction( gg_trg_New_Quest_Dialog, function Trig_New_Quest_Button_Actions )
endfunction
local integer i = 1
loop
//this is one of the 4's you have to change if you want to change the max number of active quests.
if i > 4 then
return false
exitwhen true
elseif udg_QuestId == 0 then
return true
exitwhen true
endif
set i = i + 1
endloop
if GetPlayerId(GetTriggerPlayer()) != 0 then
return false
endif
return true
endfunction
function Trig_New_Quest_Button_Actions takes nothing returns nothing
call DialogClear(udg_QuestDialog[0])
call DialogSetMessage( udg_QuestDialog[0], "Choose new quest difficulty" )
set udg_DialogButton[0] = DialogAddButton( udg_QuestDialog[0], "Easy",1 )
set udg_DialogButton[1] = DialogAddButton( udg_QuestDialog[0], "Medium",2 )
set udg_DialogButton[2] = DialogAddButton( udg_QuestDialog[0], "Hard",3 )
call DialogDisplay(Player(0),udg_QuestDialog[0],true)
endfunction
//===========================================================================
function InitTrig_New_Quest_Dialog takes nothing returns nothing
set gg_trg_New_Quest_Dialog = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_New_Quest_Dialog, Player(0), "new", true )
call TriggerAddCondition( gg_trg_New_Quest_Dialog, Condition( function Trig_New_Quest_Button_Conditions ) )
call TriggerAddAction( gg_trg_New_Quest_Dialog, function Trig_New_Quest_Button_Actions )
endfunction
Questlist Command
function Trig_Questlist_Command_Actions takes nothing returns nothing
local integer i = 1
local unit u
local integer id
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Current Quests:")
loop
if udg_QuestId != 0 then
set id = udg_QuestId
call DisplayTextToPlayer(GetTriggerPlayer(),0,0," ")
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,udg_QuestName[id])
if udg_QuestTarget[id] != null then
set u = CreateUnit(Player(12),udg_QuestTarget[id],0,0,0)
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(udg_KillCount)+"/"+I2S(udg_QuestKills[id])+" "+GetUnitName(u)+"s.")
call RemoveUnit(u)
else
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,udg_QuestMessage[udg_QuestId])
endif
endif
set i = i + 1
//this is one of the 4's you have to change if you want to change the max number of active quests.
exitwhen i > 4
endloop
endfunction
//===========================================================================
function InitTrig_Questlist_Command takes nothing returns nothing
set gg_trg_Questlist_Command = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Questlist_Command, Player(0), "questlist", true )
call TriggerAddAction( gg_trg_Questlist_Command, function Trig_Questlist_Command_Actions )
endfunction
function Trig_Questlist_Command_Actions takes nothing returns nothing
local integer i = 1
local unit u
local integer id
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"Current Quests:")
loop
if udg_QuestId != 0 then
set id = udg_QuestId
call DisplayTextToPlayer(GetTriggerPlayer(),0,0," ")
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,udg_QuestName[id])
if udg_QuestTarget[id] != null then
set u = CreateUnit(Player(12),udg_QuestTarget[id],0,0,0)
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,I2S(udg_KillCount)+"/"+I2S(udg_QuestKills[id])+" "+GetUnitName(u)+"s.")
call RemoveUnit(u)
else
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,udg_QuestMessage[udg_QuestId])
endif
endif
set i = i + 1
//this is one of the 4's you have to change if you want to change the max number of active quests.
exitwhen i > 4
endloop
endfunction
//===========================================================================
function InitTrig_Questlist_Command takes nothing returns nothing
set gg_trg_Questlist_Command = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Questlist_Command, Player(0), "questlist", true )
call TriggerAddAction( gg_trg_Questlist_Command, function Trig_Questlist_Command_Actions )
endfunction
... and create these global variables:
QuestTaken Boolean Array
QuestDialog Dialog Array
DialogButton Dialog Button Array
KillCount Integer Array
QuestId Integer Array
QuestKills Integer Array
QuestRewardGold Integer Array
QuestRewardLumber Integer Array
QuestRewardItem Item Array
QuestCompletedMessage String Array
QuestMessage String Array
QuestName String Array
QuestTarget Unit-Type Array