my automated quest generator. uses my Party library
note alot of the user implementation is near the bottom of the system library. It was meant for me; I didn't modulate the system and the implementation.
JASS:
library Quest initializer init requires UnitIndexer
globals
private constant string questColor = "ffa07a"
private constant string beforeQuestName = "|cff"+questColor+"Quest \""
private constant string afterQuestName = "\" completed!|r"
private constant string beforeQuestNameAccepted = beforeQuestName
private constant string afterQuestNameAccepted = "\" is now available"
private Table unitTable
private Table triggerAttachedData
private TableArray questTable
private QuestInteractListener array interactTable
private QuestInteractListener array interactLevelTable
private integer interactLevelTablePos = 0
private QuestAPI array questArray
private constant integer MAX_NUM_QUESTS = 50
private constant integer STAGE_INDICE_INDENT = 8192
private constant integer GLOBAL_FINISH = 1127483638
private constant integer KILL_FINISH = 1147383627
private constant integer STAGE_FINISH = 1147683616
private constant integer EXCLAMATION_POINT_ID = 'h00E'
private integer NUM_PLAYERS = 12
private TableArray sequenceTable
private QuestInstance array listOfQuests
private QuestAPI array listeningQuestsArray
private integer listeningQuestsIndex = 0
private integer listOfQuestsIndex = -1
QuestAPI bountyQuest
public integer QUESTSYSTEM_GOLDTOADD = 0
public integer QUESTSYSTEM_LUMBTOADD = 0
public integer QUESTSYSTEM_EXPTOADD = 0
public integer QUESTSYSTEM_ITEMTYPE = 0
public integer QUESTSYSTEM_ITEMAMOUNT = 0
public player QUESTSYSTEM_PLAYER
public unit QUESTSYSTEM_LASTUNIT
public unit QUESTSYSTEM_TRIGGERUNIT
public unit QUESTSYSTEM_TEMPUNIT
public widget QUESTSYSTEM_TEMPWIDGET
public unit QUESTSYSTEM_TRIGGERPLAYERUNIT
public trigger QUESTSYSTEM_MAINTRIGGER = null
public trigger QUESTSYSTEM_TEMPTRIGGER = null
public integer QUESTSYSTEM_RESPONSETYPE = 0
private constant real MESSAGE_DURATION = 15
private trigger last
endglobals
struct QuestAPI extends array
implement Alloc
private integer indice
private integer stageIndice
private integer rewardIndice
private integer interactIndice
private boolean isInInteractTable
private integer interactPosition
private Table instances
private string questName
private integer instancesCount
private boolean active
private force hasFinished
private QuestInteractListener starter
//! textmacro Init
set questTable = TableArray[29]
set unitTable = TableArray[MAX_NUM_QUESTS]
// set playerProgressTable = TableArray[NUM_PLAYERS]
set sequenceTable = TableArray[MAX_NUM_QUESTS]
set triggerAttachedData = Table.create()
//! endtextmacro
static method create takes string name returns thistype
local thistype this = thistype.allocate()
set indice = 0
set rewardIndice = 0
set stageIndice = -1
set instances = Table.create()
set instancesCount = 0
//call questArray[this].flush()
set questArray[this] = this
set interactIndice = 0
set interactPosition = 0
set isInInteractTable = false
set active = false
set hasFinished = CreateForce()
set starter = 0
set questName = name
return this
endmethod
method startNextStage takes string notification returns thistype
set questTable[this][(stageIndice + 1) + (STAGE_INDICE_INDENT * indice)] = STAGE_FINISH
set questTable[this].string[(STAGE_INDICE_INDENT - 2) + (STAGE_INDICE_INDENT * indice)] = notification
set indice = indice + 1
set stageIndice = -1
return this
endmethod
method addInteractQuestStarter takes widget interactee, boolean enabled, string onInteract, string onQuestAccept returns thistype
set starter = QuestInteractListener.create(this,interactee,questName,onInteract,onQuestAccept,enabled)
return this
endmethod
method addStarterWithLvl takes integer lvl, widget interactee, string onInteract, string onQuestAccept returns thistype
set starter = QuestInteractListener.create(this,interactee,questName,onInteract,onQuestAccept,false)
call starter.setLevel(lvl,true)
return this
endmethod
method getStarter takes nothing returns QuestInteractListener
return starter
endmethod
method addInteract takes widget interactee, string onInteract, real hoverHeight returns thistype
set stageIndice = stageIndice + 7
set questTable[this][(stageIndice - 6) + (STAGE_INDICE_INDENT * indice)] = -1
set questTable[this][(stageIndice - 5) + (STAGE_INDICE_INDENT * indice)] = GetHandleId(interactee)
set questTable[this].string[stageIndice-4 + (STAGE_INDICE_INDENT * indice)] = onInteract
set questTable[this].boolean[stageIndice-3 + (STAGE_INDICE_INDENT * indice)] = false
set questTable[this].real[stageIndice-2 + (STAGE_INDICE_INDENT * indice)] = hoverHeight
set questTable[this].real[stageIndice-1 + (STAGE_INDICE_INDENT * indice)] = GetWidgetX(interactee)
set questTable[this].real[stageIndice + (STAGE_INDICE_INDENT * indice)] = GetWidgetY(interactee)
return this
endmethod
method addKillType takes integer unitType, integer amount, string onKill, string onWhole, real x, real y returns thistype
set stageIndice = stageIndice + 7
set questTable[this][(stageIndice - 6) + (STAGE_INDICE_INDENT * indice)] = -2
set questTable[this][(stageIndice - 5) + (STAGE_INDICE_INDENT * indice)] = unitType
set questTable[this][stageIndice-4 + (STAGE_INDICE_INDENT * indice)] = amount
set questTable[this].string[stageIndice-3 + (STAGE_INDICE_INDENT * indice)] = onKill
set questTable[this].string[stageIndice-2 + (STAGE_INDICE_INDENT * indice)] = onWhole
set questTable[this].real[(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = x
set questTable[this].real[(stageIndice) + (STAGE_INDICE_INDENT * indice)] = y
return this
endmethod
method addItemType takes integer itemType, integer charges, string onSingle, string onWhole, real x, real y returns thistype
set stageIndice = stageIndice + 7
set questTable[this][(stageIndice - 6) + (STAGE_INDICE_INDENT * indice)] = -3
set questTable[this][(stageIndice - 5) + (STAGE_INDICE_INDENT * indice)] = itemType
set questTable[this][stageIndice -4+ (STAGE_INDICE_INDENT * indice)] = charges
set questTable[this].string[stageIndice -3+ (STAGE_INDICE_INDENT * indice)] = onSingle
set questTable[this].string[stageIndice-2 + (STAGE_INDICE_INDENT * indice)] = onWhole
set questTable[this].real[stageIndice-1 + (STAGE_INDICE_INDENT * indice)] = x
set questTable[this].real[stageIndice + (STAGE_INDICE_INDENT * indice)] = y
return this
endmethod
method addTriggerRun takes trigger t returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = -121
set questTable[this].trigger[(stageIndice ) + (STAGE_INDICE_INDENT * indice)] = t
return this
endmethod
method addTriggerRunIfDestroyed takes trigger t returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = -122
set questTable[this].trigger[(stageIndice ) + (STAGE_INDICE_INDENT * indice)] = t
return this
endmethod
method hasPlayerCompleted takes player p returns boolean
return IsPlayerInForce(p,hasFinished)
endmethod
static method triggerAdd takes nothing returns boolean
local QuestAPI this = triggerAttachedData[GetHandleId(GetTriggeringTrigger())]
if this == 0 then
return false
endif
call this.triggerRun(GetTriggeringTrigger())
return false
endmethod
method addTrigger takes real x, real y returns trigger
local trigger t = CreateTrigger()
set last = t
call TriggerAddCondition(t, function thistype.triggerAdd)
set triggerAttachedData[GetHandleId(t)] = this
set stageIndice = stageIndice + 5
set questTable[this][(stageIndice - 4) + (STAGE_INDICE_INDENT * indice)] = -4
set questTable[this].trigger[stageIndice-3 + (STAGE_INDICE_INDENT * indice)] = t
set questTable[this].boolean[stageIndice-2 + (STAGE_INDICE_INDENT * indice)] = false
set questTable[this].real[stageIndice-1 + (STAGE_INDICE_INDENT * indice)] = x
set questTable[this].real[stageIndice + (STAGE_INDICE_INDENT * indice)] = y
return last
endmethod
method addFinish takes nothing returns thistype
call startNextStage(null)
set questTable[this][STAGE_INDICE_INDENT * (indice)] = GLOBAL_FINISH
set questTable[this].string[1+(STAGE_INDICE_INDENT * indice)] = beforeQuestName + questName + afterQuestName
set indice = indice + 1
set stageIndice = -1
return this
endmethod
method addUnitReward takes integer unitId, integer amount returns thistype
set stageIndice = stageIndice + 3
set questTable[this][(stageIndice - 2) + (STAGE_INDICE_INDENT * indice)] = -1
set questTable[this][(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = unitId
set questTable[this][stageIndice-0 + (STAGE_INDICE_INDENT * indice)] = amount
return this
endmethod
method addItemReward takes integer itemId, integer amount returns thistype
set stageIndice = stageIndice + 3
set questTable[this][(stageIndice - 2) + (STAGE_INDICE_INDENT * indice)] = -2
set questTable[this][(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = itemId
set questTable[this][stageIndice + (STAGE_INDICE_INDENT * indice)] = amount
return this
endmethod
method addGoldReward takes integer amount returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = -3
set questTable[this][stageIndice + (STAGE_INDICE_INDENT * indice)] = amount
return this
endmethod
method addWoodReward takes integer amount returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice - 1) + (STAGE_INDICE_INDENT * indice)] = -4
set questTable[this][stageIndice + (STAGE_INDICE_INDENT * indice)] = amount
return this
endmethod
method addExpReward takes integer amount returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice -1) + (STAGE_INDICE_INDENT * indice)] = -5
set questTable[this][(stageIndice) + (STAGE_INDICE_INDENT * indice)] = amount
return this
endmethod
method addQuestStartReward takes Quest s returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice -1) + (STAGE_INDICE_INDENT * indice)] = -6
set questTable[this][(stageIndice) + (STAGE_INDICE_INDENT * indice)] = s
return this
endmethod
method addQuestEnableReward takes Quest s returns thistype
set stageIndice = stageIndice + 2
set questTable[this][(stageIndice -1) + (STAGE_INDICE_INDENT * indice)] = -7
set questTable[this][(stageIndice) + (STAGE_INDICE_INDENT * indice)] = s
return this
endmethod
method isFinished takes player p returns boolean
return IsPlayerInForce(p,hasFinished)
endmethod
method isInStage takes player p, integer stage returns boolean
local integer i = 0
if isFinished(p) then
return true
endif
loop
exitwhen i >= instancesCount
if QuestInstance(instances[i]).containsPlayer(p) then
return QuestInstance(instances[i]).getStage() >= stage
endif
set i = i + 1
endloop
return false
endmethod
method triggerRun takes trigger t returns nothing
local integer i = 0
if not active then
return
endif
loop
exitwhen i == instancesCount
if QuestInstance(instances[i]).triggerFulfill(t) then
return
endif
set i = i + 1
endloop
endmethod
//method addInteractStarter takes widget u returns nothing
//endmethod
method start takes Party p returns QuestInstance
local QuestInstance f = QuestInstance.create(this).start(p)
set active = true
set instances[instancesCount] = f
set instancesCount = instancesCount + 1
return f
endmethod
method finish takes integer inst, boolean good, Party p returns nothing
local integer i = 0
if good then
call p.populateForce(hasFinished)
endif
loop
exitwhen i == instancesCount
if inst == instances[i] then
set instances[i] = instances[instancesCount - 1]
set instancesCount = instancesCount - 1
if instancesCount == 0 then
set active = false
endif
return
endif
set i = i + 1
endloop
endmethod
public static method onRepick takes player p returns nothing
local integer i = 0
loop
exitwhen i == listeningQuestsIndex
call interactTable[i].reset(p)
set i = i + 1
endloop
endmethod
private static method onInit takes nothing returns nothing
//! runtextmacro Init()
endmethod
endstruct
struct QuestInteractListener extends array
implement Alloc
widget interact
string onInt
string onAcc
Table b
integer interactPosition
integer levelPosition
Table levelPinged
boolean usesLevel
boolean defaultEnabled
string questName
integer level
unit exc
QuestAPI root
public static method create takes QuestAPI roott, widget interacter, string name, string onInteract, string onAccept, boolean enable returns thistype
local thistype this = thistype.allocate()
local integer i = 0
local integer l
if enable then
set l = 1
else
set l = 0
endif
if roott == 0 then
return 0
endif
set root = roott
set b = Table.create()
loop
exitwhen i == 10
set b[i]=l
set i = i + 1
endloop
set onInt = onInteract
set level = 0
set questName = name
set onAcc = onAccept
set interact = interacter
set interactPosition = listeningQuestsIndex
set listeningQuestsIndex = listeningQuestsIndex + 1
set interactTable[interactPosition] = this
set defaultEnabled = enable
set exc = CreateUnit(Player(15), EXCLAMATION_POINT_ID, GetWidgetX(interact), GetWidgetY(interact), 0)
call ShowUnit(exc,enable)
return this
endmethod
public method setLevel takes integer reqLevel, boolean enableWhenReady returns nothing
local integer i = 0
set levelPinged = Table.create()
set usesLevel = true
set level = reqLevel
set levelPosition = interactLevelTablePos
set interactLevelTablePos = interactLevelTablePos + 1
set interactLevelTable[levelPosition] = this
if enableWhenReady then
set defaultEnabled = true
loop
exitwhen i == 10
set b[i]=1
set i=i+1
endloop
endif
endmethod
public method lvlCheck takes integer newLevel, player p returns nothing
if levelPinged.boolean[GetPlayerId(p)] then
return
endif
if newLevel >= level then
set levelPinged.boolean[GetPlayerId(p)] = true
if b[GetPlayerId(p)] == 1 then
call enable(p)
endif
endif
endmethod
public method isEnabled takes player p returns boolean
return b[GetPlayerId(p)] != 0
endmethod
public method enable takes player p returns thistype
set b[GetPlayerId(p)] = 1
call PingMinimap(GetWidgetX(interact), GetWidgetY(interact),5)
call ShowUnit(exc, b[GetPlayerId(GetLocalPlayer())] != 99)
call TimedTextBoolean(15,b[GetPlayerId(GetLocalPlayer())] != 99, beforeQuestNameAccepted+questName+afterQuestNameAccepted)
return this
endmethod
public method enableParty takes Party p returns thistype
local integer i =0
local real dur
loop
exitwhen i == 10
if p.doesContainPlayer(Player(i)) then
set b[i]=1
endif
set i = i+1
endloop
if p.doesContainPlayer(GetLocalPlayer()) then
set dur = 5
else
set dur = 0
endif
call PingMinimap(GetWidgetX(interact), GetWidgetY(interact),dur)
call ShowUnit(exc, b[GetPlayerId(GetLocalPlayer())] != 99)
call TimedTextBoolean(15,dur == 5, beforeQuestNameAccepted+questName+afterQuestNameAccepted)
return this
endmethod
public method disable takes player p returns thistype
set b[GetPlayerId(p)] = 0
call ShowUnit(exc, b[GetPlayerId(GetLocalPlayer())] != 99)
return this
endmethod
public method destroy takes nothing returns nothing
set interactTable[interactPosition] = interactTable[listeningQuestsIndex - 1]
set listeningQuestsIndex = listeningQuestsIndex - 1
set interact = null
call b.flush()
call deallocate()
endmethod
public method reset takes player p returns nothing
if defaultEnabled then
set b[GetPlayerId(p)] = 1
else
set b[GetPlayerId(p)] = 0
endif
set levelPinged.boolean[GetPlayerId(p)] = false
call ShowUnit(exc, not usesLevel and b[GetPlayerId(GetLocalPlayer())] != 99 and b[GetPlayerId(GetLocalPlayer())] != 0)
endmethod
public method onInteract takes widget u, player target returns boolean
local integer i = GetPlayerId(target)
local integer i2 = 0
local integer a = 0
local Party p
if u != interact or b[i] == 99 or integer(Party.getParty(target)) < 7 then
return false
endif
if usesLevel and level > Party.getParty(target).getLevelReq() then
// call TimedText(target,MESSAGE_DURATION,"|cff"+questColor+"Notice:|r Your party is too low level to accept this quest")
return false
endif
loop
exitwhen i2 == 10
if Party.getParty(target).doesContainPlayer(Player(i2)) and b[i2] == 0 then
// call TimedText(target,MESSAGE_DURATION,"|cff"+questColor+"Notice:|r Player "+I2S(i)+" does not have this quest unlocked")
return false
endif
set i2 = i2 + 1
endloop
if b[i] == 5 then
set p = Party.getParty(target)
call root.start(p)
call TimedTextBoolean(15,Party.getParty(target).doesContainPlayer(GetLocalPlayer()),onAcc)
loop
if IsPlayerInForce(Player(a), p.getForce()) then
set b[a] = 99
endif
set a = a + 1
exitwhen a == 11
endloop
elseif b[i] == 1 then
set b[i] = 5
call TimedTextBoolean(15,Party.getParty(target).doesContainPlayer(GetLocalPlayer()),onInt)
endif
call ShowUnit(exc, b[GetPlayerId(GetLocalPlayer())] != 99)
return true
endmethod
endstruct
struct QuestInstance
private QuestAPI root
private Party party
private integer stage
public integer thisIndex
private unit lastTrigger
private unit array lastTriggerUnit[11]
private integer array i[11]
private Table progress
private Table currentProgress
private Table onDestroy
private integer onDestIndex
public static method create takes QuestAPI root returns thistype
local thistype this = thistype.allocate()
set this.root = root
set stage = -1
set onDestIndex = 0
set onDestroy = Table.create()
set progress = Table.create()
set listOfQuestsIndex = listOfQuestsIndex + 1
set listOfQuests[listOfQuestsIndex] = this
set thisIndex = listOfQuestsIndex
set currentProgress = Table.create()
return this
endmethod
public method destroy takes nothing returns nothing
local integer i = 0
local integer i2 = 0
call root.getStarter().enableParty(party)
set listOfQuests[listOfQuestsIndex].thisIndex = thisIndex
set listOfQuests[thisIndex] = listOfQuests[listOfQuestsIndex]
set listOfQuests[listOfQuestsIndex] = 0
set listOfQuestsIndex = listOfQuestsIndex - 1
set lastTrigger = null
set i = 0
loop
exitwhen i == onDestIndex
call runTriggerForForce(party, onDestroy.trigger[i])
set i = i + 1
endloop
call onDestroy.destroy()
set i = 0
loop
set i2 = -progress[i]
exitwhen i2 == -STAGE_FINISH
if i2 == 1 then
call SetWidgetLife(progress.widget[i+4], 0)
set i = i + 6
elseif i2 == 2 or i2 == 3 then
set i = i + 7
elseif i2 ==4 then
set i = i + 5
endif
set i = i + 1
endloop
call progress.destroy()
call currentProgress.destroy()
call root.finish(this,false,0)
call this.deallocate()
endmethod
public method endQuest takes nothing returns nothing
set listOfQuests[listOfQuestsIndex].thisIndex = thisIndex
set listOfQuests[thisIndex] = listOfQuests[listOfQuestsIndex]
set listOfQuests[listOfQuestsIndex] = 0
set listOfQuestsIndex = listOfQuestsIndex - 1
set lastTrigger = null
call progress.destroy()
call currentProgress.destroy()
call onDestroy.destroy()
call root.finish(this,true,party)
call this.deallocate()
endmethod
public method containsPlayer takes player p returns boolean
return party.doesContainPlayer(p)
endmethod
public method getStage takes nothing returns integer
return stage
endmethod
public method start takes Party p returns thistype
if stage != -1 then
call TimedTextAll(MESSAGE_DURATION,"FAIL")
endif
set this.party = p
call party.startQuest(this)
call nextStage()
return this
endmethod
private method nextStage takes nothing returns nothing
local integer forLoop = 0
local integer i = 0
local integer numIteration = -1
local widget w
local Table t = questTable[root]
call progress.flush()
call currentProgress.flush()
set onDestIndex = 0
call onDestroy.flush()
set stage = stage + 1
if t[stage * STAGE_INDICE_INDENT] == GLOBAL_FINISH then
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), t.string[1+(stage * STAGE_INDICE_INDENT)])
call finish()
return
elseif t.string[(STAGE_INDICE_INDENT - 2)+(STAGE_INDICE_INDENT * (stage-1))] != null then
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), t.string[(STAGE_INDICE_INDENT - 2)+((stage-1) * STAGE_INDICE_INDENT)])
endif
loop
set i = t[forLoop + (stage * STAGE_INDICE_INDENT)]
if i < 0 then
set i = -i
if i == -STAGE_FINISH then
set progress[numIteration] = STAGE_FINISH
return
elseif i == 1 then
set numIteration = numIteration + 7
set forLoop = forLoop + 6
set w = I2W(t[forLoop-5+ (stage * STAGE_INDICE_INDENT)])
set progress[numIteration - 6] = -1
set progress[numIteration - 5] = t[forLoop-5+ (stage * STAGE_INDICE_INDENT)]
set progress.string[numIteration - 4] = t.string[forLoop-4+ (stage * STAGE_INDICE_INDENT)]
set progress.boolean[numIteration - 3] = false
set progress.unit[numIteration-2] = CreateUnit(Player(10),EXCLAMATION_POINT_ID, GetWidgetX(w), GetWidgetY(w), 0)
call ShowUnit(progress.unit[numIteration-2], party.doesContainPlayer(GetLocalPlayer()))
call UnitAddAbility(progress.unit[numIteration-2], 'Amrf')
call SetUnitFlyHeight(progress.unit[numIteration-2], t.real[forLoop-2+ (stage * STAGE_INDICE_INDENT)], 100000)
call UnitRemoveAbility(progress.unit[numIteration-2], 'Amrf')
call party.addPing(t.real[forLoop-1+ (stage * STAGE_INDICE_INDENT)],t.real[forLoop+ (stage * STAGE_INDICE_INDENT)])
set w = null
elseif i == 2 or i == 3 then
set numIteration = numIteration + 7
set forLoop = forLoop + 6
if i == 2 then
set progress[numIteration - 6] = -2
else
set progress[numIteration - 6] = -3
endif
set progress[numIteration - 5] = t[forLoop - 5 + (stage * STAGE_INDICE_INDENT)]
set progress[numIteration-4] = t[forLoop-4 + (stage * STAGE_INDICE_INDENT)]
set progress.string[numIteration-3] = t.string[forLoop-3 + (stage * STAGE_INDICE_INDENT)]
set progress.string[numIteration-2] = t.string[forLoop-2 + (stage * STAGE_INDICE_INDENT)]
elseif i == 4 then
set numIteration = numIteration + 5
set forLoop = forLoop + 4
set progress[numIteration - 4] = -4
set progress.trigger[numIteration - 3] = t.trigger[forLoop - 3+ (stage * STAGE_INDICE_INDENT)]
set progress.boolean[numIteration-2] = false
elseif i == 121 then
set forLoop = forLoop + 1
call runTriggerForForce(party, t.trigger[forLoop + (stage*STAGE_INDICE_INDENT)])
elseif i == 122 then
set forLoop = forLoop + 1
set onDestroy.trigger[onDestIndex] = t.trigger[forLoop + (stage*STAGE_INDICE_INDENT)]
set onDestIndex = onDestIndex + 1
endif
endif
set forLoop = forLoop + 1
exitwhen t[forLoop + (stage * STAGE_INDICE_INDENT)] == 0
endloop
set progress[numIteration + 1] = STAGE_FINISH
endmethod
public method notifyClosure takes nothing returns nothing
call destroy()
endmethod
public method finish takes nothing returns nothing
local integer forLoop = 0
local integer i = 0
local player playerNoob
local Table t = questTable[root]
set stage = stage + 1
loop
if t[forLoop + (stage * STAGE_INDICE_INDENT)] == -1 then
loop
set playerNoob = Player(i)
set i = i + 1
exitwhen i > 11
endloop
set forLoop = forLoop + 2
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -2 then
set i = 0
loop
set playerNoob = Player(i)
if party.doesContainPlayer(playerNoob) then
set QUESTSYSTEM_ITEMTYPE = t[forLoop+1 + (stage * STAGE_INDICE_INDENT)]
set QUESTSYSTEM_ITEMAMOUNT = t[forLoop+2 + (stage * STAGE_INDICE_INDENT)]
set QUESTSYSTEM_TRIGGERUNIT = udg_PlayerUnit[i+1]
set QUESTSYSTEM_TRIGGERPLAYERUNIT = udg_PlayerUnit[i+1]
//set QUESTSYSTEM_TRIGGERUNIT = lastTrigger
//set QUESTSYSTEM_TRIGGERPLAYERUNIT = lastTriggerUnit[GetPlayerId(playerNoob)]
set QUESTSYSTEM_RESPONSETYPE = 4
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
endif
set i = i + 1
exitwhen i > 11
endloop
set forLoop = forLoop + 2
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -3 then
set i = 0
loop
set playerNoob = Player(i)
if party.doesContainPlayer(playerNoob) then
set QUESTSYSTEM_GOLDTOADD = t[forLoop+1 + (stage * STAGE_INDICE_INDENT)]
set QUESTSYSTEM_TRIGGERUNIT = lastTrigger
set QUESTSYSTEM_PLAYER = playerNoob
set QUESTSYSTEM_TRIGGERPLAYERUNIT = lastTriggerUnit[GetPlayerId(playerNoob)]
set QUESTSYSTEM_RESPONSETYPE = 1
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
//call SetPlayerState(playerNoob, PLAYER_STATE_RESOURCE_GOLD, t[forLoop+1 + (stage * STAGE_INDICE_INDENT)])
endif
set i = i + 1
exitwhen i > 11
endloop
set forLoop = forLoop + 1
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -4 then
set i = 0
loop
set playerNoob = Player(i)
if party.doesContainPlayer(playerNoob) then
set QUESTSYSTEM_LUMBTOADD = t[forLoop+1 + (stage * STAGE_INDICE_INDENT)]
set QUESTSYSTEM_TRIGGERUNIT = lastTrigger
set QUESTSYSTEM_TRIGGERPLAYERUNIT = lastTriggerUnit[GetPlayerId(playerNoob)]
set QUESTSYSTEM_PLAYER = playerNoob
set QUESTSYSTEM_RESPONSETYPE = 2
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
endif
set i = i + 1
exitwhen i > 11
endloop
set forLoop = forLoop + 1
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -5 then
set i = 0
loop
set playerNoob = Player(i)
if party.doesContainPlayer(playerNoob) then
set QUESTSYSTEM_EXPTOADD = t[forLoop+1 + (stage * STAGE_INDICE_INDENT)]
set QUESTSYSTEM_TRIGGERUNIT = udg_PlayerUnit[i+1]
set QUESTSYSTEM_TRIGGERPLAYERUNIT = udg_PlayerUnit[i+1]
set QUESTSYSTEM_PLAYER = playerNoob
set QUESTSYSTEM_RESPONSETYPE = 6
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
endif
set i = i + 1
exitwhen i > 11
endloop
set forLoop = forLoop + 1
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -6 then
call QuestAPI(t[forLoop+1 + (stage * STAGE_INDICE_INDENT)]).start(party)
set forLoop = forLoop + 1
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -7 then
call QuestAPI(t[forLoop+1 + (stage * STAGE_INDICE_INDENT)]).getStarter().enableParty(party)
set forLoop = forLoop + 1
elseif t[forLoop + (stage * STAGE_INDICE_INDENT)] == -121 then
call runTriggerForForce(party, t.trigger[forLoop+1 + (stage*STAGE_INDICE_INDENT)])
set forLoop = forLoop + 1
endif
set forLoop = forLoop + 1
exitwhen t[forLoop + (stage * STAGE_INDICE_INDENT)] == 0
endloop
//set p = null
//set listOfQuests[listOfQuestsIndex].thisIndex = thisIndex
// set listOfQuests[thisIndex] = listOfQuests[listOfQuestsIndex]
//set listOfQuests[listOfQuestsIndex] = 0
// set listOfQuestsIndex = listOfQuestsIndex - 1
// call progress.flush()
// set playerNoob = null
call this.endQuest()
// call nextStage()
endmethod
public method checkFinish takes nothing returns nothing
local integer forLoop = 0
local integer f
local Table t = questTable[root]
loop
set f =progress[forLoop]
if f == -2 or f == -3 then
if progress[forLoop + 2] != KILL_FINISH then
return
else
set forLoop = forLoop + 6
endif
elseif f == -1 then
if progress.boolean[forLoop + 3] == false then
return
else
set forLoop = forLoop + 6
endif
elseif f == -4 then
if progress.boolean[forLoop + 2] == false then
return
else
set forLoop = forLoop + 4
endif
endif
set forLoop = forLoop + 1
if progress[forLoop] == STAGE_FINISH or progress[forLoop] == 0 then
call nextStage()
return
endif
endloop
endmethod
public method unitFulfill takes unit u, unit killer returns boolean
local integer forLoop = 0
local integer unitId
if not party.doesContainPlayer(GetOwningPlayer(killer)) then
return false
endif
set unitId = GetUnitTypeId(u)
loop
if progress[forLoop] == -2 then
if unitId == progress[forLoop + 1] and progress[forLoop + 2] != GLOBAL_FINISH then
set lastTrigger = killer
set lastTriggerUnit[GetPlayerId(GetOwningPlayer(killer))] = killer
set currentProgress[forLoop] = currentProgress[forLoop] + 1
if currentProgress[forLoop] == progress[forLoop + 2] then
set progress[forLoop + 2] = KILL_FINISH
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), progress.string[forLoop + 4])
call checkFinish()
return true
else
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), ReplaceString(progress.string[forLoop + 3],"$NUMB$",0,I2S(currentProgress[forLoop])+"/"+I2S( progress[forLoop + 2] )))
return true
endif
endif
endif
set forLoop = forLoop + 1
exitwhen progress[forLoop] == STAGE_FINISH or progress[forLoop] == 0
endloop
return false
endmethod
public method itemFulfill takes item u, unit killer returns boolean
local integer forLoop = 0
local integer itemId = GetItemTypeId(u)
if not party.doesContainPlayer(GetOwningPlayer(killer)) then
return false
endif
loop
if progress[forLoop] == -3 then
if itemId == progress[forLoop + 1] and progress[forLoop + 2] != KILL_FINISH then
set lastTrigger = killer
set lastTriggerUnit[GetPlayerId(GetOwningPlayer(killer))] = killer
if GetTotalItemCharges(killer,itemId) >= progress[forLoop + 2] then
call ReduceItemCharges(killer, itemId, progress[forLoop + 2])
set progress[forLoop + 2] = KILL_FINISH
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), progress.string[forLoop + 4])
call checkFinish()
else
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), ReplaceString(progress.string[forLoop + 3],"$NUMB$",0,I2S(GetTotalItemCharges(killer,itemId))+"/"+I2S( progress[forLoop + 2] )))
endif
return true
endif
endif
set forLoop = forLoop + 1
exitwhen progress[forLoop] == STAGE_FINISH
endloop
return false
endmethod
public method interactFulfill takes unit triggerUnit, widget victimUnit returns boolean
local integer forLoop = 0
if not party.doesContainPlayer(GetOwningPlayer(triggerUnit)) then
return false
endif
loop
if progress[forLoop] == -1 then
if GetHandleId(victimUnit) == progress[forLoop + 1] and progress.boolean[forLoop + 3] == false then
set lastTrigger = triggerUnit
set lastTriggerUnit[GetPlayerId(GetOwningPlayer(triggerUnit))] = triggerUnit
if progress.string[forLoop+2] != null then
call TimedTextBoolean(MESSAGE_DURATION,party.doesContainPlayer(GetLocalPlayer()), progress.string[forLoop + 2])
endif
set progress.boolean[forLoop + 3] = true
call SetWidgetLife(progress.widget[forLoop + 4],0)
call checkFinish()
return true
else
set forLoop = forLoop + 6
endif
endif
set forLoop = forLoop + 1
exitwhen progress[forLoop] == STAGE_FINISH or progress[forLoop] == 0
endloop
return false
endmethod
method triggerFulfill takes trigger t returns boolean
local integer forLoop = 0
if not party.doesContainPlayer(applicablePlayer) then
return false
endif
loop
if progress[forLoop] == -4 then
if progress.trigger[forLoop+1] == t and progress.boolean[forLoop+2] == false then
set progress.boolean[forLoop+2] = true
call checkFinish()
return true
else
set forLoop = forLoop + 2
endif
endif
set forLoop = forLoop + 1
exitwhen progress[forLoop] == STAGE_FINISH or progress[forLoop] == 0
endloop
return false
endmethod
endstruct
struct QuestMain
private static method onInteract takes nothing returns nothing
local integer i = 0
local unit t
local widget k
local boolean aCQ = false
local boolean bCQ = false
local player p
set QUESTSYSTEM_RESPONSETYPE = 8
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
set k = QUESTSYSTEM_TEMPWIDGET
if k == null then
return
endif
set QUESTSYSTEM_RESPONSETYPE = 7
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
set t = QUESTSYSTEM_TEMPUNIT
set p = GetOwningPlayer(t)
loop
if not aCQ then
if listOfQuests[i] != 0 then
if listOfQuests[i].interactFulfill(t,k) then
exitwhen true
endif
else
set aCQ = true
endif
endif
if not bCQ then
if interactTable[i] != 0 then
if interactTable[i].onInteract(k,p) then
exitwhen true
endif
else
set bCQ = true
endif
endif
exitwhen aCQ and bCQ
set i = i + 1
endloop
set t = null
set k = null
endmethod
static method onUnitDeath takes nothing returns boolean
local integer i = 0
local unit u = GetTriggerUnit()
local unit u2 = GetKillingUnit()
loop
if listOfQuests[i] != null then
if listOfQuests[i].unitFulfill(u,u2) then
set u = null
set u2 = null
return false
endif
else
exitwhen true
endif
set i = i + 1
endloop
set u = null
set u2 = null
return false
endmethod
static method onItemPickup takes nothing returns boolean
local integer i = 0
local item it = GetManipulatedItem()
local unit u = GetTriggerUnit()
if GetItemTypeId(it) == GetItemUserData(it) or GetItemTypeId(it) == 'I01Q' then
set it = null
set u = null
return false
endif
loop
if listOfQuests[i] != null then
if listOfQuests[i].itemFulfill(it, u) then
exitwhen true
endif
else
exitwhen true
endif
set i = i + 1
endloop
set it = null
set u = null
return false
endmethod
private static method onLevelUp takes nothing returns boolean
local integer i = 0
local player p = GetOwningPlayer(GetTriggerUnit())
local integer lvl = GetHeroLevel(udg_PlayerUnit[GetPlayerId(p)+1])
loop
exitwhen i == interactLevelTablePos
call QuestInteractListener(interactLevelTable[i]).lvlCheck(lvl,p)
set i = i + 1
endloop
return false
endmethod
private static method onInit takes nothing returns nothing
local trigger t
local integer fly_low = 50
local integer fly_mid = 100
local integer fly_high = 125
//! runtextmacro GotumLocals()
local QuestAPI starterQuest
local QuestAPI recipes
local QuestAPI recipes2
local QuestAPI temp
local QuestAPI q
set t = CreateTrigger()
set QUESTSYSTEM_TEMPTRIGGER = t
set QUESTSYSTEM_RESPONSETYPE = 5
if QUESTSYSTEM_MAINTRIGGER != null then
call TriggerEvaluate(QUESTSYSTEM_MAINTRIGGER)
endif
call TriggerAddAction(t, function thistype.onInteract)
set t = null
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t, Filter(function thistype.onUnitDeath))
set t = null
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t, Filter(function thistype.onItemPickup))
set t = null
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_LEVEL)
call TriggerAddCondition(t, Filter(function thistype.onLevelUp))
set t = null
//! textmacro del
set temp = QuestAPI.create("Gotum : Spider Venom").addStarterWithLvl(5,gg_unit_h00H_0310, "|cff"+questColor+/*
*/ "Alchemist|r: Hello again adventurer! I assume that your previous venture was successful. Fortunately for you, I'm running low on spider venom that I use to make my health potions."+/*
*/ " Would you mind getting me some from the spiders? I'll be sure to reward you for your troubles.",/*
*/ "|cff"+questColor+"Alchemist|r: These are the same spiders that you killed for your bounty. Collect 10 vials of spider venom and bring them back to me")/*
*/ .addItemType('I02G',10,"|cff"+questColor+"Spider Venom|r: $NUMB$","|cff"+questColor+"All Spider Venom collected|r",0,0)
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function CDS.StartSpiderVenom))
call temp.addTriggerRun(t)
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function CDS.EndSpiderVenom))
call temp.addTriggerRunIfDestroyed(t).startNextStage("|cff"+questColor+"Notice|r: Return to the Alchemist to claim your reward.").addInteract(gg_unit_h00H_0310, "|cff"+questColor+"Alchemist|r: Great! This will do nicely. You get the first batch!",fly_high)/*
*/
call temp.addTriggerRun(t)
set t = null
call temp.addFinish().addExpReward(300)
//! endtextmacro
//! runtextmacro GotumStarterQuests()
set bountyQuest = QuestAPI.create("Intro : Bounties").addInteractQuestStarter(gg_unit_h00B_0223,false, "|cff"+questColor+"Bounty Agent:|r Hello! Looking to go out to kill some enemies? Doing a quest? Snag some bounties for whatever you're hunting for and you'll be leveling faster than ever"/*
*/, "|cff"+questColor+"Bounty Agent:|r Okay, purchase a spider bounty from me and you can embark on your first adventure")/*
*/.addItemType('I005',1,""," ",0,0).startNextStage("|cff"+questColor+"Bounty Agent:|r To start the bounty, click on it. To turn it in, click on it again. Come to me when you have completed the bounty. Good luck on your first adventure!")
call BountySystem.setOnBounty(bountyQuest.addTrigger(0,0))
call bountyQuest.addFinish().addExpReward(60)
set recipes2 = QuestAPI.create("Intro : Alchemist").addInteractQuestStarter(gg_unit_h00H_0310, false, "|cff"+questColor+"Alchemist|r : Hello. I sell potions. Would you like to buy one?",/*
*/ "|cff"+questColor+"Alchemist|r : Excellent! Purchase 10 inferior health and mana potions")/*
*/ .addItemType('I01P', 10, "|cff"+questColor+"Progress:|r $NUMB$ Inferior Health Potions purchased", "|cff"+questColor+"Progress|r : All inferior health potions purchased!",0,0)/*
*/ .addItemType('I01T', 10, "|cff"+questColor+"Progress|r: $NUMB$ Inferior Mana Potions purchased", "|cff"+questColor+"Progress:|r All inferior mana potions purchased",0,0)/*
*/ .startNextStage("|cff"+questColor+"Progress:|r Return to the Alchemist for your reward").addInteract(gg_unit_h00H_0310,"|cff"+questColor+"Alchemist|r : Excellent! Talk to the bounty agent for your first adventure",0)/*
*/ .addFinish().addExpReward(60).addQuestEnableReward(bountyQuest)
set recipes = QuestAPI.create("Intro : Blacksmith")/*
*/ .addItemType('I006',0,"ERROR"," ",0,0).startNextStage("|cff"+questColor+"Blacksmith |r: Great! Now. Go into your inventory and take off a piece of starting gear along with your recipe and the scrap I gave you and put them in the recipe area and double click the recipe")/*
*/ .addInteractQuestStarter(gg_unit_h00C_0139,false,"|cff"+questColor+"Quest Description|r : Hello, In this village I am the master of crafting. I can tell you everything you need to know about upgrading your basic gear."+/*
*/ "\n\n|cff"+questColor+"Goal|r : Combine your weak iron scraps with my Gotum Gear + recipe and one of your pieces of gear to form an upgraded piece of gear." + /*
*/ "\n\n|cff"+questColor+"Information|r : To combine items, open your inventory and put all three items in the area to the right of your equipment and double click the recipe. The new item will be sent to your inventory"+/*
*/ "\n\n|cff"+questColor+"Talk to me again to accept this quest","|cff"+questColor+"Blacksmith|r : Buy a Gotum + recipe from me to combine your recipe and move to the next stage")
call CustomInventory.setOnRecipe(recipes.addTrigger(0,0))
call recipes.addFinish().addExpReward(100).addGoldReward(200).addQuestEnableReward(recipes2)
// set RECIPES_trigger =
set starterQuest = QuestAPI.create("Intro : Introductions")/*
*/.addInteract(gg_unit_h00D_0307, "|cff"+questColor+"Ship Captain|r : Good day. When you are ready to leave Elohim, I am the person you will talk to.",fly_low).addInteract(gg_unit_h00C_0139, "|cff"+questColor+"Blacksmith|r : Hello. My job in this town is to sell building manuscripts and recipes.",fly_low).addInteract(gg_unit_h00B_0223, "|cff"+questColor+"Bounty Agent|r Hello. My job is to sell bounties to adventurers. If you are going on a quest you should grab bounties to maximize your time.",fly_high)/*
*/.addInteract(gg_unit_h00H_0310 , "|cff"+questColor+"Alchemist|r : Hello, I am the Alchemist. My job in town is to sell potions and other chemical creation formulas.",fly_mid)/*
*/.startNextStage("|cff"+questColor+"Information|r : Talk to the woman to complete your quest").addInteract(gg_unit_h00L_0367,"|cff"+questColor+"Woman|r : Have you acquainted yourself with the members" /*
*/ + "of the town? Good. Here are some iron scraps, talk to the Blacksmith about using and upgrading gear",fly_low).addFinish().addItemReward('I00U',0).addExpReward(60).addQuestEnableReward(recipes)/*
*/.addInteractQuestStarter(gg_unit_h00L_0367, true, "|cff"+questColor+"Quest Description|r : I would like you walk around town and talk to the villagers\n\n|cff"+questColor+"Goal|r \n - Talk to the Ship Captain" + "\n - Talk to the Blacksmith \n - Talk to the Bounty Agent\n - Talk to the Alchemist\n\n|cff"+questColor+"Reward|r : 150 Gold, 500 EXP, Quest 'Alchemy'\n\n|cff"+questColor+"Hint|r : The Ship Captain is located in the"/*
*/ + " topleft of the village, the Blacksmith is located in the mid-top of the village, the Bounty Agent is"/*
*/ + "located at the entrance of the forest, and the Alchemist is located in the bottomright of the village.\n\n|cff"+questColor+"Talk to me again to accept this quest|r","Quest |cff"+questColor+"Introductions|r accepted|r")
//call starterQuest.start(Player(0))
endmethod
endstruct
private function init takes nothing returns nothing
call QuestAPI.create(" ")
call QuestInteractListener.create(0,null,"", "","",false)
endfunction
module QuestListenerModule //do not touch this if you dont know what your doing
private static method response takes nothing returns boolean
if QUESTSYSTEM_RESPONSETYPE == 1 then
call thistype.addGold(QUESTSYSTEM_PLAYER, QUESTSYSTEM_GOLDTOADD, QUESTSYSTEM_TRIGGERUNIT, QUESTSYSTEM_TRIGGERPLAYERUNIT)
elseif QUESTSYSTEM_RESPONSETYPE == 2 then
call thistype.addLumber(QUESTSYSTEM_PLAYER, QUESTSYSTEM_LUMBTOADD, QUESTSYSTEM_TRIGGERUNIT, QUESTSYSTEM_TRIGGERPLAYERUNIT)
elseif QUESTSYSTEM_RESPONSETYPE == 3 then
elseif QUESTSYSTEM_RESPONSETYPE == 4 then
call thistype.addItem(QUESTSYSTEM_ITEMTYPE, QUESTSYSTEM_TRIGGERUNIT, QUESTSYSTEM_TRIGGERPLAYERUNIT, QUESTSYSTEM_ITEMAMOUNT)
elseif QUESTSYSTEM_RESPONSETYPE == 5 then
call thistype.addEventToInteractTrigger(QUESTSYSTEM_TEMPTRIGGER)
elseif QUESTSYSTEM_RESPONSETYPE == 6 then
call thistype.addExp(QUESTSYSTEM_PLAYER, QUESTSYSTEM_EXPTOADD, QUESTSYSTEM_TRIGGERUNIT, QUESTSYSTEM_TRIGGERPLAYERUNIT)
elseif QUESTSYSTEM_RESPONSETYPE == 7 then
set QUESTSYSTEM_TEMPUNIT = thistype.getInteractTrigger()
elseif QUESTSYSTEM_RESPONSETYPE == 8 then
set QUESTSYSTEM_TEMPWIDGET = thistype.getInteractVictim()
elseif QUESTSYSTEM_RESPONSETYPE == 9 then
elseif QUESTSYSTEM_RESPONSETYPE == 10 then
endif
return false
endmethod
private static method onInit takes nothing returns nothing
set QUESTSYSTEM_MAINTRIGGER = CreateTrigger()
call TriggerAddCondition(QUESTSYSTEM_MAINTRIGGER, Filter(function thistype.response))
endmethod
endmodule
endlibrary
JASS:
//! textmacro GotumLocals
local QuestAPI q1
local QuestAPI q2
//! endtextmacro
//! textmacro del2
set temp = QuestAPI.create("Gotum : Spider Venom").addStarterWithLvl(5,gg_unit_h00H_0310, "|cff"+questColor+/*
*/ "Alchemist|r : Hello again adventurer! I assume that your previous venture was successful. Fortunately for you, I'm running low on spider venom that I use to make my health potions."+/*
*/ " Would you mind getting me some from the spiders? I'll be sure to reward you for your troubles.",/*
*/ "|cff"+questColor+"Alchemist|r : These are the same spiders that you killed for your bounty. Collect 10 vials of spider venom and bring them back to me")/*
*/ .addItemType('I02G',10,"|cff"+questColor+"Spider Venom|r : $NUMB$","|cff"+questColor+"All Spider Venom collected|r",0,0)
//! endtextmacro
//! textmacro GotumStarterQuests
set q1 = QuestAPI.create("Gotum: Waypoints").addStarterWithLvl(3,gg_unit_h00D_0307, "|cff"+questColor+/*
*/"Ship Captain|r : Have you seen the waypoint in town? When you use it, you will be able to teleport to any other waypoint you've visited. These are incredibly helpful for traversing these lands. To practice with this system, I'd like you to find the Woods waypoint and transfer back to town with it." /*
*/, "|cff"+questColor+"Ship Captain|r : Once you find it, take it back to here and talk to me.")
set WaypointQuest.onWaypointUsage = q1.addTrigger(0,0)
call q1.startNextStage("|cff"+questColor+"Notice|r : Return to the Ship Captain to claim your reward.").addInteract(gg_unit_h00H_0310, "|cff"+questColor+"Ship Captain|r : It... it is! I've never touched this poison before, I've only seen the spider. Congratulatons! Many good tidings and blessings to come!",fly_high)
call q1.addTriggerRun(t).addFinish().addExpReward(1200).addItemReward('I02I', 5)
set q1 = QuestAPI.create("Gotum: Lesser Potions of Expertise").addInteractQuestStarter(gg_unit_h00H_0310,false, "|cff"+questColor+/*
*/"Alchemist|r : How did you like those potions? Great, arent they? The good part is they're only the tip of the iceberg! There are so many spiders in the forest. I havent had an adventerer as strong as you in a while, but if you go deep into the forest you can find" +/*
*/" infected and giant spiders. They're venon allows me to make a potion that improves your fighting power for a short period of time. If you can kill them, I can make you some." , "|cff"+questColor+"Alchemist|r : Good luck, adventurer! I would recommend talking to the ship captain if you haven't already as his quest can be completed on the way to the deep forest and will help you cut down on travel times.")/*
*/ .addItemType('I02K',10,"|cff"+questColor+"Mutated Spider Venom|r : $NUMB$","|cff"+questColor+"All Mutated Spider Venom collected|r",0,0)
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function CDS.MutatedStartSpiderVenom))
call q1.addTriggerRun(t)
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function CDS.MutatedEndSpiderVenom))
call q1.addTriggerRunIfDestroyed(t).startNextStage("|cff"+questColor+"Notice|r : Return to the Alchemist to claim your reward.").addInteract(gg_unit_h00H_0310, "|cff"+questColor+"Alchemist|r : It has been years since I've used these chemicals, oh I feel young all over again.",fly_high)
call q1.addTriggerRun(t).addFinish().addExpReward(450).addItemReward('I02I', 5).addQuestEnableReward(q1)
set t = null
set q2 = QuestAPI.create("Gotum: Lesser Potions of Healing").addStarterWithLvl(3,gg_unit_h00H_0310, "|cff"+questColor+/*
*/"Alchemist|r : Well hello again. Now that you are hooked on my potions, I am going to need some assistance. Can you collect some spider venom for me? I need some to make my potions."/*
*/, "|cff"+questColor+"Alchemist|r : These are the same spiders that you killed for your bounty. Collect 10 vials of spider venom and bring them back to me")/*
*/ .addItemType('I02G',10,"|cff"+questColor+"Spider Venom|r : $NUMB$","|cff"+questColor+"All Spider Venom collected|r",0,0)
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function CDS.StartSpiderVenom))
call q2.addTriggerRun(t)
set t = CreateTrigger()
call TriggerAddCondition(t, Filter(function CDS.EndSpiderVenom))
call q2.addTriggerRunIfDestroyed(t).startNextStage("|cff"+questColor+"Notice|r : Return to the Alchemist to claim your reward.").addInteract(gg_unit_h00H_0310, "|cff"+questColor+"Alchemist|r : Great! This will do nicely. You get the first batch!",fly_high)
call q2.addTriggerRun(t).addFinish().addExpReward(300).addItemReward('I02H', 20).addQuestEnableReward(q1)
set t = null
//! endtextmacro
JASS:
library QuestListener requires Quest
struct Listener
private static method addGold takes player p, integer amount, unit turnIn, unit lastInteractedUnitForPlayer returns nothing
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + amount)
endmethod
private static method addExp takes player p, integer amount, unit turnIn, unit lastInteractedUnitForPlayer returns nothing
call SetHeroXP(turnIn, GetHeroXP(turnIn) + amount, true)
endmethod
private static method addLumber takes player p, integer amount, unit turnIn, unit lastInteractedUnitForPlayer returns nothing
call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) + amount)
endmethod
private static method addItem takes integer itemType, unit turnIn, unit lastInteractedUnitForPlayer, integer amount returns nothing
local item i = CreateItem(itemType,0,0)
call UnitAddItem(lastInteractedUnitForPlayer, i)
call SetItemCharges(i, amount)
set i = null
endmethod
private static method createUnits takes integer unitType, integer amount, unit turnIn, unit lastInteractedUnitForPlayer returns nothing
endmethod
private static method addEventToInteractTrigger takes trigger interactTrigger returns nothing
call TriggerRegisterAnyUnitEventBJ(interactTrigger,EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
call TriggerAddCondition(interactTrigger, Filter(function thistype.interactCondition))
endmethod
private static method interactCondition takes nothing returns boolean
return RAbsBJ(GetUnitX(GetTriggerUnit()) - GetWidgetX(GetOrderTarget())) < 250 and RAbsBJ(GetUnitY(GetTriggerUnit()) - GetWidgetY(GetOrderTarget())) < 250
endmethod
private static method getInteractTrigger takes nothing returns unit
return GetTriggerUnit()
endmethod
private static method getInteractVictim takes nothing returns widget
return GetOrderTarget()
endmethod
implement QuestListenerModule
endstruct
endlibrary
note alot of the user implementation is near the bottom of the system library. It was meant for me; I didn't modulate the system and the implementation.