//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
//create global quests like this
QuestUtils sample1
QuestUtils sample2
//create glbal quest items like this
QuestItem qItem1
QuestItem qItem2
QuestItem qItem3
endglobals
Name | Type | is_array | initial_value |
u | unit | No |
//TESH.scrollpos=297
//TESH.alwaysfold=0
[B][SIZE="3"][COLOR="Yellow"]QuestUtils v1.4[/COLOR][/SIZE][/B]
Just a Quest System that makes life easy...
[hidden=QuestUtils (Main System)]
[jass]
/*
===QuestUtils v1.4
===By Mckill2009
This is an alternative to GUI Quest creation, very easy to use if you follow the instructions
written in this sample map...
API:
struct QuestUtils extends array
static method create takes boolean required, boolean discovered returns thistype
method operator []= takes string title, string description returns nothing
method operator questIcon= takes string iconPath returns nothing
method operator completed= takes boolean b returns nothing
method operator failed= takes boolean b returns nothing
method operator enable= takes boolean b returns nothing
method operator discover= takes boolean b returns nothing
method operator completed takes nothing returns boolean
method operator discovered takes nothing returns boolean
method operator enabled takes nothing returns boolean
method operator required takes nothing returns boolean
method destroy takes nothing returns nothing
struct QuestItem extends array
static method create takes QuestUtils index, string text returns thistype
method operator text= takes string text returns nothing
method operator completed= takes boolean b returns nothing
method operator completed takes nothing returns boolean
method destroy takes nothing returns nothing
*/
library QuestUtils uses optional QuestSounds
globals
private constant integer QUEST_LIMIT = 100
endglobals
struct QuestUtils extends array
quest q
private static thistype instance = 0
static method create takes boolean required returns thistype
local thistype this
if instance==QUEST_LIMIT then
debug call BJDebugMsg("QuestUtils ERROR: Maximum quest is: "+I2S(QUEST_LIMIT))
else
set instance = instance + 1
set this = instance
set .q = CreateQuest()
call QuestSetRequired(.q, required)
endif
return this
endmethod
method operator []= takes string title, string description returns nothing
call QuestSetTitle(.q, title)
call QuestSetDescription(.q, description)
call FlashQuestDialogButton()
endmethod
method operator questIcon= takes string iconPath returns nothing
call QuestSetIconPath(.q, iconPath)
endmethod
method operator completed= takes boolean b returns nothing
call QuestSetCompleted(.q, b)
endmethod
method operator failed= takes boolean b returns nothing
call QuestSetFailed(.q, b)
endmethod
method operator enable= takes boolean b returns nothing
call QuestSetEnabled(.q, b)
endmethod
method operator discover= takes boolean b returns nothing
call QuestSetDiscovered(.q, b)
endmethod
method operator completed takes nothing returns boolean
return IsQuestCompleted(.q)
endmethod
method operator discovered takes nothing returns boolean
return IsQuestDiscovered(.q)
endmethod
method operator enabled takes nothing returns boolean
return IsQuestEnabled(.q)
endmethod
method operator required takes nothing returns boolean
return IsQuestRequired(.q)
endmethod
method destroy takes nothing returns nothing
call DestroyQuest(.q)
set .q = null
set .q = instance.q
set instance = instance - 1
endmethod
endstruct
struct QuestItem extends array
questitem qi
private static thistype instance = 0
static method create takes QuestUtils index, string text returns thistype
local thistype this
set instance = instance + 1
set this = instance
set .qi = QuestCreateItem(index.q)
call QuestItemSetDescription(.qi, text)
call FlashQuestDialogButton()
return this
endmethod
method operator text= takes string text returns nothing
call QuestItemSetDescription(.qi, text)
call FlashQuestDialogButton()
endmethod
method operator completed= takes boolean b returns nothing
call QuestItemSetCompleted(.qi, b)
call FlashQuestDialogButton()
endmethod
method operator completed takes nothing returns boolean
return IsQuestItemCompleted(.qi)
endmethod
method destroy takes nothing returns nothing
set .qi = null
set .qi = instance.qi
set instance = instance - 1
endmethod
endstruct
endlibrary
[/jass]
[/hidden]
[hidden=QuestSounds (Sub-System)]
[jass]
/*
===QuestSounds v1.0
===By Mckill2009
Sounds should be in Mp3 format
*/
library QuestSounds
//sample: call PlayCompletedSound()
//! textmacro Sound takes Func, Snd
function Play$Func$Sound takes nothing returns nothing
call StartSound(bj_quest$Snd$Sound)
endfunction
//! endtextmacro
//! runtextmacro Sound("Completed","Completed")
//! runtextmacro Sound("Discovered","Discovered")
//! runtextmacro Sound("Failed","Failed")
//! runtextmacro Sound("Hint","Hint")
//! runtextmacro Sound("ItemAcquired","ItemAcquired")
//! runtextmacro Sound("Secret","Secret")
//! runtextmacro Sound("Updated","Updated")
//! runtextmacro Sound("Warning","Warning")
//sample: call PlaySound(gg_snd_SOUNDFILENAME, false)
//if killWheDone is true, it will destroy the sound and clears the leak but
//if you use the sound again, then you should set it to false
function PlayCustomSound takes sound soundHandle, boolean killWhenDone returns nothing
call StartSound(soundHandle)
if killWhenDone then
call KillSoundWhenDone(soundHandle)
endif
endfunction
endlibrary
[/jass]
[/hidden]
[hidden=Demo and Tutorials]
I'm bad at tutorials, so if you wanna add something, Ima credit you!
[hidden=vJass]
[jass]
scope QuestUtilsDEMO
struct QuestUtilsDEMO extends array
//Globals are recommended but in this example I just use locals
static method run takes nothing returns nothing
local QuestUtils Q
local QuestUtils Q1
local QuestItem q1
local QuestItem q2
local QuestItem q3
local QuestItem q4
set Q = Q.create(true)
set Q1 = Q1.create(false)
call BJDebugMsg(I2S(Q)+" Quest Created")
call BJDebugMsg(I2S(Q1)+" Quest Created")
set Q["QUEST TITLE HERE"] = "QUEST DESCRIPTION HERE"
set Q.questIcon = "ReplaceableTextures\\CommandButtons\\BTNDivineIntervention.blp"
set q1 = q1.create(Q, "I AM #1 QUEST ITEM")
set q2 = q2.create(Q, "I AM #2 QUEST ITEM")
set q3 = q3.create(Q, "I AM #3 QUEST ITEM")
set q4 = q4.create(Q, "I AM #4 QUEST ITEM")
set q1.text = "QUEST ITEM #1 HAS CHANGED TEXT"
set q1.completed = true
call q1.destroy() //questItem #1 will never be recalled
set q1.text = "QUEST ITEM #1" //this cant be displayed anymore coz it's been destroyed
set q4.text = "QUEST ITEM #4"
set Q.enable = true
if Q.enabled then
call BJDebugMsg("QUEST ENABLED")
else
call BJDebugMsg("QUEST NOT ENABLED")
endif
set Q.completed = false
if Q.completed then
call BJDebugMsg("QUEST COMPLETED")
else
call BJDebugMsg("QUEST NOT COMPLETED")
endif
//call Q.destroy()
//set Q.questIcon = "ReplaceableTextures\\CommandButtons\\BTNDivineIntervention.blp"
endmethod
static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function thistype.run)
endmethod
endstruct
endscope
[/jass]
[/hidden]
[hidden=GUI]
[trigger]
QuestUtils DEMO GUI
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
-------- We will use a global variable for this demo created via global blocks so that we can access the code outside this trigger --------
-------- you may create global blocks above your map script (same as the sample) or via libraries or scopes --------
-------- ================== --------
-------- Set up the quest first, true==required, false==optional --------
Custom script: set sample1 = sample1.create(true)
-------- Inside this >> [] is the title and after this = is the description as written below --------
Custom script: set sample1["QUEST TITLE HERE"] = "QUEST DESCRIPTION HERE"
Custom script: set sample1.questIcon = "ReplaceableTextures\\CommandButtons\\BTNDivineIntervention.blp"
-------- Setting up the quest item, these natives are not available for GUI --------
-------- take note that the sample1 is your #1 indexed quest, so we will put our questItem to the #1 quest created, we already referenced it as: --------
-------- sample1 --------
Custom script: set qItem1 = qItem1.create(sample1, "I AM #1 QUEST ITEM")
Custom script: set qItem2 = qItem2.create(sample1, "I AM #2 QUEST ITEM")
Custom script: set qItem3 = qItem3.create(sample1, "I AM #3 QUEST ITEM")
-------- Now let's do these: --------
-------- Change the text to our qItem1 --------
-------- Destroy qItem2 --------
-------- Complete the qItem3 --------
Custom script: set qItem1.text = "QUEST ITEM #1 HAS CHANGED TEXT"
Custom script: call qItem2.destroy()
Custom script: set qItem3.completed = false
-------- Now let's use qtem3 outside this function --------
-------- say we will RUN the GUI RUN trigger --------
Game - Display to (All players) the text: We will run the GUI...
Game - Display to (All players) the text: The qItem3 is compl...
Wait 7.00 seconds
Trigger - Run GUI RUN <gen> (ignoring conditions)
[/trigger]
[trigger]
GUI RUN
Events
Conditions
Actions
-------- See the advantages of globals in this system?, easy implementation! --------
-------- qItem3 will return true coz we already declared completed from the previous trigger --------
Custom script: if qItem3.completed then
Game - Display to (All players) the text: qItem3 is COMPLETED
Unit - Create 1 Blood Mage for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Custom script: else
Unit - Create 1 Paladin for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
Game - Display to (All players) the text: qItem3 is NOT COMPL...
Custom script: endif
-------- ================== --------
-------- if you want to complete the whole quest then --------
Custom script: set sample1.completed = true
-------- Or if you want the quest to be failed --------
Custom script: set sample1.failed = true
[/trigger]
[/hidden]
[/hidden]
[hidden=Changelogs]
v1.4
- Name convention applied
v1.3
- Nullings applied
v1.2
- All methods replaced by operators
- Added quest limit
v1.1
- Most methods replaced by operators
- Quest Sounds created in separate snippet, as suggested by the moderator
- Most changes applied from suggestions by Magtheridon96 and Nesthaurus
[/hidden]
[hidden=Credits]
- Nesthaurus and Magtheridon96 for his suggestions
[/hidden]
//TESH.scrollpos=9
//TESH.alwaysfold=0
/*
===QuestSounds v1.0
===By Mckill2009
Sounds should be in Mp3 format
*/
library QuestSounds
//sample: call PlayCompletedSound()
//! textmacro Sound takes Func, Snd
function Play$Func$Sound takes nothing returns nothing
call StartSound(bj_quest$Snd$Sound)
endfunction
//! endtextmacro
//! runtextmacro Sound("Completed","Completed")
//! runtextmacro Sound("Discovered","Discovered")
//! runtextmacro Sound("Failed","Failed")
//! runtextmacro Sound("Hint","Hint")
//! runtextmacro Sound("ItemAcquired","ItemAcquired")
//! runtextmacro Sound("Secret","Secret")
//! runtextmacro Sound("Updated","Updated")
//! runtextmacro Sound("Warning","Warning")
//sample: call PlaySound(gg_snd_SOUNDFILENAME, false)
//if killWheDone is true, it will destroy the sound and clears the leak but
//if you use the sound again, then you should set it to false
function PlayCustomSound takes sound soundHandle, boolean killWhenDone returns nothing
call StartSound(soundHandle)
if killWhenDone then
call KillSoundWhenDone(soundHandle)
endif
endfunction
endlibrary
//TESH.scrollpos=14
//TESH.alwaysfold=0
/*
===QuestUtils v1.4
===By Mckill2009
This is an alternative to GUI Quest creation, very easy to use if you follow the instructions
written in this sample map...
API:
struct QuestUtils extends array
static method create takes boolean required, boolean discovered returns thistype
method operator []= takes string title, string description returns nothing
method operator questIcon= takes string iconPath returns nothing
method operator completed= takes boolean b returns nothing
method operator failed= takes boolean b returns nothing
method operator enable= takes boolean b returns nothing
method operator discover= takes boolean b returns nothing
method operator completed takes nothing returns boolean
method operator discovered takes nothing returns boolean
method operator enabled takes nothing returns boolean
method operator required takes nothing returns boolean
method destroy takes nothing returns nothing
struct QuestItem extends array
static method create takes QuestUtils index, string text returns thistype
method operator text= takes string text returns nothing
method operator completed= takes boolean b returns nothing
method operator completed takes nothing returns boolean
method destroy takes nothing returns nothing
*/
library QuestUtils uses optional QuestSounds
globals
private constant integer QUEST_LIMIT = 100
endglobals
struct QuestUtils extends array
quest q
private static thistype instance = 0
static method create takes boolean required returns thistype
local thistype this
if instance==QUEST_LIMIT then
debug call BJDebugMsg("QuestUtils ERROR: Maximum quest is: "+I2S(QUEST_LIMIT))
else
set instance = instance + 1
set this = instance
set .q = CreateQuest()
call QuestSetRequired(.q, required)
endif
return this
endmethod
method operator []= takes string title, string description returns nothing
call QuestSetTitle(.q, title)
call QuestSetDescription(.q, description)
call FlashQuestDialogButton()
endmethod
method operator questIcon= takes string iconPath returns nothing
call QuestSetIconPath(.q, iconPath)
endmethod
method operator completed= takes boolean b returns nothing
call QuestSetCompleted(.q, b)
endmethod
method operator failed= takes boolean b returns nothing
call QuestSetFailed(.q, b)
endmethod
method operator enable= takes boolean b returns nothing
call QuestSetEnabled(.q, b)
endmethod
method operator discover= takes boolean b returns nothing
call QuestSetDiscovered(.q, b)
endmethod
method operator completed takes nothing returns boolean
return IsQuestCompleted(.q)
endmethod
method operator discovered takes nothing returns boolean
return IsQuestDiscovered(.q)
endmethod
method operator enabled takes nothing returns boolean
return IsQuestEnabled(.q)
endmethod
method operator required takes nothing returns boolean
return IsQuestRequired(.q)
endmethod
method destroy takes nothing returns nothing
call DestroyQuest(.q)
set .q = null
set .q = instance.q
set instance = instance - 1
endmethod
endstruct
struct QuestItem extends array
questitem qi
private static thistype instance = 0
static method create takes QuestUtils index, string text returns thistype
local thistype this
set instance = instance + 1
set this = instance
set .qi = QuestCreateItem(index.q)
call QuestItemSetDescription(.qi, text)
call FlashQuestDialogButton()
return this
endmethod
method operator text= takes string text returns nothing
call QuestItemSetDescription(.qi, text)
call FlashQuestDialogButton()
endmethod
method operator completed= takes boolean b returns nothing
call QuestItemSetCompleted(.qi, b)
call FlashQuestDialogButton()
endmethod
method operator completed takes nothing returns boolean
return IsQuestItemCompleted(.qi)
endmethod
method destroy takes nothing returns nothing
set .qi = null
set .qi = instance.qi
set instance = instance - 1
endmethod
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope QuestUtilsDEMO
struct QuestUtilsDEMO extends array
//Globals are recommended but in this example I just use locals
static method run takes nothing returns nothing
local QuestUtils Q
local QuestUtils Q1
local QuestItem q1
local QuestItem q2
local QuestItem q3
local QuestItem q4
set Q = Q.create(true)
set Q1 = Q1.create(false)
call BJDebugMsg(I2S(Q)+" Quest Created")
call BJDebugMsg(I2S(Q1)+" Quest Created")
set Q["QUEST TITLE HERE"] = "QUEST DESCRIPTION HERE"
set Q.questIcon = "ReplaceableTextures\\CommandButtons\\BTNDivineIntervention.blp"
set q1 = q1.create(Q, "I AM #1 QUEST ITEM")
set q2 = q2.create(Q, "I AM #2 QUEST ITEM")
set q3 = q3.create(Q, "I AM #3 QUEST ITEM")
set q4 = q4.create(Q, "I AM #4 QUEST ITEM")
set q1.text = "QUEST ITEM #1 HAS CHANGED TEXT"
set q1.completed = true
call q1.destroy() //questItem #1 will never be recalled
set q1.text = "QUEST ITEM #1" //this cant be displayed anymore coz it's been destroyed
set q4.text = "QUEST ITEM #4"
set Q.enable = true
if Q.enabled then
call BJDebugMsg("QUEST ENABLED")
else
call BJDebugMsg("QUEST NOT ENABLED")
endif
set Q.completed = false
if Q.completed then
call BJDebugMsg("QUEST COMPLETED")
else
call BJDebugMsg("QUEST NOT COMPLETED")
endif
//call Q.destroy()
//set Q.questIcon = "ReplaceableTextures\\CommandButtons\\BTNDivineIntervention.blp"
endmethod
static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function thistype.run)
endmethod
endstruct
endscope