• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Quest System Suggestions and Ideas

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
I believe I am an intermediate vJass Coder and have been working on this system for a little while. Was wondering if the community can help me in anyway make it more efficient or better.

The system is to allow you to make some dynamic quests with a few lines of code, Kill Quests, Item Quests, (Things that aren't added Yet: Event, Travel, Chain, and Story Quests) Basically it should allow the user to easily mix and match different quest types.

JASS:
//================================================================================//
//                 SHADOWFLARE'S DYNAMIC QUEST MAKING SYSTEM
//                                  v1.0
//
// 
//
//
//
//
//
//
//
//
//================================================================================//
library QuestLib initializer Init

globals
//================================================================================//
//CONFIGURABLES
//=============
    private constant string     QUEST_STRING        = "|cff008000"
    private constant string     QUEST_UPDATE        = "QUEST UPDATE:"
    private constant string     QUEST_ACCEPT        = "QUEST ACCEPTED"
    private constant string     QUEST_COMPLETE      = "QUEST COMPLETED"
    private constant string     EXP_COLOR           = "|cffc100c1"
    private constant string     GOLD_COLOR          = "|cffffff00"
    private constant string     REWARD_COLOR        = "|cffffff3c"
    private constant integer    STRING_CAP          = 5
    private constant string     COMPLETE_COLOR      = "|cff808080"
    private constant string     UPDATE_STRING       = " - "
    private constant string     Lr                  = "|r"
    private constant integer    TALK_ID             = 'A000'
    private constant real       UPDATE_DURATION     = 7.0
    private constant integer    MAX_PLAYERS         = 10
    private constant string     NEW_QUEST_AVAILABLE = "war3mapImported\\Green Light.mdx"
    private constant string     QUEST_ACCEPTED      = "war3mapImported\\floating questionmark_v2.mdx"
    private constant string     QUEST_FINISHED      = "Abilities\\Spells\\Other\\Aneu\\AneuCaster.mdl"
    private constant integer    DUMMY_REWARD        = 'h001'
//ENDCONFIGURABLES
//================================================================================//
    private integer MAX_QUESTS = 0
    private dialog array GiverMenu[MAX_PLAYERS]
    private button array QButton[12]
    private integer index = 0
    public hashtable q = InitHashtable()
endglobals
//================================================================================//
// Public Functions
//=================
function GetQuestIndex takes integer StructName returns integer
    local QuestLib_Quest SN = StructName
    return SN.qindex
endfunction
//Ex. call GetQuestIndex(LoadInteger(q, 1, 13))
//Ex. call GetStartingQuests(GetUnitLevel(bj_lastCreatedUnit), bj_lastCreatedUnit)
function GetStartingQuests takes unit u returns nothing
    local integer i = 0
    local integer ii = 0
    local string s = NEW_QUEST_AVAILABLE
    local QuestLib_Quest dat
    local Players pdat = LoadInteger(q, GetPlayerId(GetOwningPlayer(u)) , 1)

    call DisplayTimedTextToPlayer(GetOwningPlayer(u), 0, 0, UPDATE_DURATION+5.0, QUEST_STRING+"AVAILABLE QUESTS")
    loop
        exitwhen i >= MAX_QUESTS
        set i = i+1
        if pdat.qalert[i] == false then
            set dat = LoadInteger(q, i, 13)
            if GetHeroLevel(u) >= dat.level then
                if pdat.qenabled[i] == false then
                    if pdat.qcomplete[i] == false then
                        call DisplayTimedTextToPlayer(GetOwningPlayer(u), 0, 0, UPDATE_DURATION+5.0, GetUnitName(dat.giver)+" has a Quest waiting for you.")
                        set pdat.qalert[i] = true
                            if (GetLocalPlayer() != GetOwningPlayer(u)) then
                                set s = ""
                            endif
                            set pdat.QuestStatus[i] = AddSpecialEffectTarget(s, dat.giver, "overhead")
                    endif
                endif
            endif
        endif
    endloop
    set i = 0

endfunction


//================================================================================//  
private struct QData
    integer array kills[STRING_CAP]
    integer array items[STRING_CAP]
    integer array count[STRING_CAP]
    boolean complete = false
endstruct

  /* Quest Types:
  Kill Quest    - 1
  Item Quest    - 2
  Travel Quest  - 3
  Event Quest   - 4
  */
public struct Quest
    boolean     reward      = false
    unit        giver       = null
    integer     qindex      = 0
    integer     level       = 0    
    integer     Qitems      = 0
    integer     ritems      = 0
    integer     exp         = 0
    integer     gold        = 0
    integer     lumber      = 0
    integer     strings     = 0
    string      intro       = ""
    string      info        = ""
    string      complete    = ""
    string      reinfo      = ""
    string      qname       = ""
    string      icon        = ""
    quest       questbox
    button Qbutton
    questitem array Qitem[STRING_CAP]
    integer array rewarditem[12]
    integer array item[STRING_CAP]
    integer array many[STRING_CAP]
    string array name[STRING_CAP]
    integer array type[STRING_CAP]
    string array end[STRING_CAP]
        // Example:
        // call (name).IntQuest(gg_unit_Ntin_0022, 1, "Missing Gears", "")
        // call IntQuest(WhatUnit, WhatLevel, WhatName, WhatIcon)
        //               Unit      Integer    String    String
        // Must Be called before any other functions are called.
method IntQuest takes unit u, integer i, string s, string c returns nothing
    set this.giver = u
    set this.level = i
    set this.qname = s
    set this.icon = c
    set index = index+1
    set this.qindex = index
    set this.strings = 0
    set MAX_QUESTS = MAX_QUESTS+1
    call CreateQuestBJ( bj_QUESTTYPE_REQ_DISCOVERED, "", "", this.icon )
    set this.questbox = GetLastCreatedQuestBJ()
    call QuestSetEnabled(this.questbox, false)
    call QuestSetTitle(this.questbox, this.qname)
    call SaveInteger(q, this.qindex, 13, this)
endmethod

//IntQuestItem( 'hpea', 3, "Peasants", 1)
//              integer integer string  integer
//          objectid    howmany     name    type

method IntQuestItem takes integer i, integer h, string n, integer t returns nothing
    local string End_String = ""
    if t == 1 then
        set  End_String = " Killed!"
    elseif t == 2 then
        set End_String = " Collected!"
    endif
    set this.strings = this.strings+1
    set this.end[this.strings] = End_String
    set this.item[this.strings] = i
    set this.many[this.strings] = h
    set this.name[this.strings] = n
    set this.type[this.strings] = t
    call CreateQuestItemBJ(this.questbox, I2S(0)+" / "+I2S(this.many[this.strings])+" "+this.name[this.strings] + End_String)
    set this.Qitem[this.strings] = GetLastCreatedQuestItemBJ()
endmethod
        
        // Example:
        // call (name).AddRItem('I000')
        // call AddRItem(WhatItemType)
        //               integer
method AddRItem takes integer i returns nothing
    set this.ritems = this.ritems+1
    set this.rewarditem[this.ritems] = i
    set this.reward = true
endmethod

        //Example:
        // call (name).AddReward(150, 50, 0)
        // call AddReward(WhatExp, WhatGold, WhatLumber)
        //                integer  integer   integer
method AddReward takes integer e, integer g, integer l returns nothing
    set this.exp = e
    set this.gold = g
    set this.lumber = l
endmethod

        //  call (name).IntStrings(/*
        //*/"This is the intro!",/* 
        //*/"This is the Info!",/* 
        //*/"This is the Complete msg!",/*
        //*/"This is the reinfo!"/*
        //*/)
method IntStrings takes string a, string b, string c, string d returns nothing
    set this.intro = a
    set this.info = b
    set this.complete = c
    set this.reinfo = d
    call QuestSetDescription(this.questbox, this.reinfo)            
endmethod

endstruct
  
private function accept takes nothing returns nothing
    local QuestLib_Quest dat
    local Players pdat = LoadInteger(q, GetPlayerId(GetTriggerPlayer()) , 1)
    local QData qdat
    local integer i = 0
    local integer ii = 0
    local integer iii = 0
    local string s = QUEST_ACCEPTED
    local string ss = NEW_QUEST_AVAILABLE
    local unit rewardu
    loop
    exitwhen i >= MAX_QUESTS
    set i = i+1
        set dat = LoadInteger(q, i, 13)
        if GetClickedButton() == dat.Qbutton then
            if pdat.qcomplete[dat.qindex] == false then
                if pdat.qenabled[dat.qindex] == false then
                    //Accepting Quest
                    set qdat = QData.create()
                    set pdat.qenabled[dat.qindex] = true
                    call DestroyEffect(pdat.QuestStatus[i])
                    
                    if (GetLocalPlayer() != GetTriggerPlayer()) then
                        set s = ""
                    endif
                    set pdat.QuestStatus[i] = AddSpecialEffectTarget(s, dat.giver, "overhead")
                    
                    loop
                        exitwhen ii > dat.strings
                        set ii = ii + 1
                        set qdat.count[i] = 0
                    endloop
                    set ii = 0
            
                    loop
                        exitwhen ii > MAX_PLAYERS
                        set pdat = LoadInteger(q, ii, 1)
                        if (GetLocalPlayer()==Player(ii) and pdat.qenabled[dat.qindex]==true) then
                            call QuestSetEnabled(dat.questbox, true)
                        endif
                    set ii = ii+1
                    endloop
                    set ii = 0
            
                    set pdat = LoadInteger(q, GetPlayerId(GetTriggerPlayer()) , 1)
                    call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, QUEST_STRING+QUEST_ACCEPT+Lr)
                    call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, "  "+dat.qname+Lr)
                    
                    loop
                    exitwhen iii >= dat.strings
                    set iii = iii+1
                        call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, UPDATE_STRING+I2S(qdat.count[iii])+" / "+I2S(dat.many[iii])+" "+dat.name[iii])
                    endloop
                    set iii = 0
                    call SaveInteger(q, dat.qindex, GetHandleId(pdat.owner), qdat)
                else
                    //Disbanding Quest
                    call DestroyEffect(pdat.QuestStatus[i])
                    
                    if (GetLocalPlayer() != GetTriggerPlayer()) then
                        set ss = ""
                    endif
                    set pdat.QuestStatus[i] = AddSpecialEffectTarget(ss, dat.giver, "overhead")
                
                    loop
                    exitwhen ii > MAX_PLAYERS
                        if (GetLocalPlayer()==Player(ii) and pdat.qenabled[dat.qindex]==true) then
                            call QuestSetEnabled(dat.questbox, false)
                        endif
                    set ii = ii+1
                    endloop
                    set ii = 0
                
                    call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, QUEST_STRING+" QUEST DISBANDED"+Lr)
                    call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, "  "+dat.qname+Lr)
                    set pdat.qenabled[dat.qindex] = false
                    set pdat.qcomplete[dat.qindex] = false
                endif
            else
                //Turning in Quest; Rewards
                set pdat.qenabled[dat.qindex] = false
                call DestroyEffect(pdat.QuestStatus[i])
                call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, QUEST_STRING+QUEST_COMPLETE+Lr)
                call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, "  "+dat.qname+Lr)
                
                if dat.gold > 0 then
                    call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, GOLD_COLOR+" + "+ I2S(dat.gold) + " Gold"+Lr)    
                endif
                
                if dat.exp > 0 then
                    call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, UPDATE_DURATION, EXP_COLOR+" + "+ I2S(dat.exp) + " EXP"+Lr)   
                endif
                
                call AdjustPlayerStateBJ( dat.gold, GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD )
                call AddHeroXP(pdat.owner, dat.exp, true)
                
                loop
                exitwhen ii > MAX_PLAYERS
                    if (GetLocalPlayer()==Player(ii) and pdat.qenabled[dat.qindex]==false) then
                        call QuestSetEnabled(dat.questbox, false)
                    endif
                set ii = ii+1
                endloop
                set ii = 0
                
                //Selecting a reward    
                if dat.reward == true then
                    set rewardu = CreateUnit(GetTriggerPlayer(), DUMMY_REWARD, 0, 0, 0)
                    
                    loop
                    exitwhen ii > dat.ritems
                        call AddItemToStock(rewardu, dat.rewarditem[ii], 1, 1)
                    set ii = ii+1
                    endloop
                    set ii = 0
                    
                    call SelectUnitForPlayerSingle(rewardu, GetTriggerPlayer())
                endif
            endif
        endif
    endloop
    set i = 0
endfunction

//Function to accept and turn in Quests
  private function talk takes nothing returns nothing
    local real angle = GetUnitFacing(GetSpellTargetUnit())+180
    local integer i = 0
    local integer ii = 0
    local QuestLib_Quest dat
    local Players pdat = LoadInteger(q, GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit())), 1)
    call DialogClear( GiverMenu[GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))] )
    //set GiverMenu[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = DialogCreate()
    loop
        exitwhen i >= MAX_QUESTS
        set i = i+1
        set dat = LoadInteger(q, i, 13)
        if dat.giver == GetSpellTargetUnit() then
            if pdat.qenabled[dat.qindex] == false then
                if pdat.qcomplete[dat.qindex] == false then
                    if GetHeroLevel(pdat.owner) >= dat.level then
                        call DialogAddButtonBJ(GiverMenu[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], dat.qname)
                        set dat.Qbutton = GetLastCreatedButtonBJ()
                    endif
               endif
            else
               if pdat.qcomplete[dat.qindex] == true then
                    call DialogAddButtonBJ(GiverMenu[GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], dat.qname+REWARD_COLOR+" (Reward)"+Lr)
                    set dat.Qbutton = GetLastCreatedButtonBJ()
                else
                    call DialogAddButtonBJ(GiverMenu[GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], dat.qname+" Disband Quest?")
                    set dat.Qbutton = GetLastCreatedButtonBJ()
                endif
            endif
        endif
    endloop
    set i = 0
    call DialogAddButtonBJ(GiverMenu[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], "Cancel")
    call DialogDisplayBJ( true, GiverMenu[GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))], GetOwningPlayer(GetSpellAbilityUnit()) )
  endfunction
  
  // DO NOT EDIT!!!
  // Function to Update all data within a Quest
  private function QuestUpdate takes player p, integer object, unit triggerer, integer questtype returns nothing
    local Players pdat = LoadInteger(q, GetPlayerId(p), 1) 
    local QuestLib_Quest dat
    local QData qdat
    local integer i = 0
    local integer ii = 0
    local integer iii = 0
    local integer c = 0
    local string s = QUEST_FINISHED
    loop
        exitwhen i >= MAX_QUESTS
        set i = i+1
        set dat = LoadInteger(q, i, 13)
        set qdat = LoadInteger(q, i, GetHandleId(pdat.owner))
        if pdat.qenabled[i] == true then
        loop
            exitwhen ii >= dat.strings
            set ii = ii + 1
            if dat.item[ii] == object then
                if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                    // Use only local code (no net traffic) within this block to avoid desyncs.
                    call ClearTextMessages()
                endif
            endif
        endloop
        set ii = 0
        endif
    endloop
    set i = 0
 
    
    //Goes Through All Quests
    loop
        exitwhen i >= MAX_QUESTS
        set i = i + 1
        set ii = 0
        set iii = 0
        set c = 0
        if pdat.qenabled[i] == true then
            set dat = LoadInteger(q, i, 13)
            set qdat = LoadInteger(q, i, GetHandleId(pdat.owner))
             loop
                exitwhen ii >= dat.strings
                set ii = ii + 1
                    if dat.item[ii] == object then
                        call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, QUEST_STRING+QUEST_UPDATE+Lr)
                        call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, "  "+dat.qname)
                    endif
            endloop
            set ii = 0
            loop
                exitwhen ii >= dat.strings
                set ii = ii + 1
                if dat.type[ii] == questtype then
                    if dat.item[ii] == object then
                       call RemoveItem( GetItemOfTypeFromUnitBJ(triggerer, object) )
                        set qdat.count[ii] = qdat.count[ii] + 1
                        if qdat.count[ii] < dat.many[ii] then
                            if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                                call QuestItemSetDescription(dat.Qitem[ii], I2S(qdat.count[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii])
                            endif
                            call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, UPDATE_STRING+I2S(qdat.count[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii])
                        else
                            set c = c+1
                            if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                                call QuestItemSetDescription(dat.Qitem[ii], COMPLETE_COLOR+I2S(dat.many[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii] + " (Complete)"+Lr)
                            endif
                            call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, COMPLETE_COLOR+UPDATE_STRING+I2S(dat.many[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii] + " (Complete)"+Lr)
                        endif
                    else
                        loop
                            exitwhen iii >= dat.strings
                            set iii = iii+1
                            if dat.item[iii] == object then
                                if dat.item[iii] != dat.item[ii] then
                                    if qdat.count[ii] < dat.many[ii] then
                                        if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                                            call QuestItemSetDescription(dat.Qitem[ii], I2S(qdat.count[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii])
                                        endif
                                        call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, UPDATE_STRING+I2S(qdat.count[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii])
                                    else
                                        set c = c+1
                                        if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                                            call QuestItemSetDescription(dat.Qitem[ii], COMPLETE_COLOR+I2S(dat.many[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii] + " (Complete)"+Lr)
                                        endif
                                        call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, COMPLETE_COLOR+UPDATE_STRING+I2S(dat.many[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii] + " (Complete)"+Lr)
                                    endif 
                                endif
                            endif
                        endloop
                        set iii = 0
                    endif
                else
                    loop
                        exitwhen iii >= dat.strings
                        set iii = iii+1
                        if dat.item[iii] == object then
                            if dat.item[iii] != dat.item[ii] then
                                if qdat.count[ii] < dat.many[ii] then
                                    if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                                        call QuestItemSetDescription(dat.Qitem[ii], I2S(qdat.count[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii])
                                    endif
                                    call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, UPDATE_STRING+I2S(qdat.count[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii])
                                else
                                    set c = c+1
                                    if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                                        call QuestItemSetDescription(dat.Qitem[ii], COMPLETE_COLOR+I2S(dat.many[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii] + " (Complete)"+Lr)
                                    endif
                                    call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, COMPLETE_COLOR+UPDATE_STRING+I2S(dat.many[ii])+" / "+I2S(dat.many[ii])+" "+dat.name[ii] + dat.end[ii] + " (Complete)"+Lr)
                                endif 
                            endif
                        endif
                    endloop
                    set iii = 0
                endif
            endloop
            set ii = 0
            if c == dat.strings then
                set pdat.qcomplete[dat.qindex] = true
                if pdat.qcomplete[dat.qindex] == true then
                    call DisplayTimedTextToPlayer(p, 0, 0, UPDATE_DURATION, UPDATE_STRING+"Return to " + GetUnitName(dat.giver))
                    if qdat.complete == false then                            
                        if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(p))) then
                            call QuestSetCompleted(dat.questbox, true)
                            call StartSound(bj_questCompletedSound)
                            call FlashQuestDialogButton()
                            call QuestSetDescription(dat.questbox, "Return to " + GetUnitName(dat.giver)+" to collect your "+REWARD_COLOR+"Reward!"+Lr)
                            call QuestSetRequired(dat.questbox, false)
                            
                        endif
                        call DestroyEffect(pdat.QuestStatus[i])
                        if (GetLocalPlayer() != GetOwningPlayer(pdat.owner)) then
                                set s = ""
                            endif
                            set pdat.QuestStatus[i] = AddSpecialEffectTarget(s, dat.giver, "overhead")
                    endif
                    set qdat.complete = true
                endif
            endif
        endif
    endloop
    set i = 0
           
    
  endfunction
  
  private function UpdateAvailableQuests takes nothing returns nothing
    call GetStartingQuests(GetTriggerUnit())
  endfunction

  private function KillDeath takes nothing returns nothing
   call QuestUpdate(GetOwningPlayer(GetKillingUnit()), GetUnitTypeId(GetTriggerUnit()), GetKillingUnit(), 1)
  endfunction
  
  private function ItemAq takes nothing returns nothing
    call QuestUpdate(GetOwningPlayer(GetManipulatingUnit()), GetItemTypeId(GetManipulatedItem()) , GetManipulatingUnit(), 2)
  endfunction
  
  private function cond takes nothing returns boolean
     if ( not ( GetSpellAbilityId() == TALK_ID ) ) then
        return false
    endif
    return true
  endfunction
  
  private function KillCond takes nothing returns boolean
      if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
        return false
    endif
    return true
  endfunction
  
  private function KillReward takes nothing returns nothing
    if DUMMY_REWARD == GetUnitTypeId(GetTriggerUnit()) then
        call RemoveUnit(GetTriggerUnit())
    endif
  endfunction
  
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    call TriggerAddAction(t, function talk)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function cond))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function KillCond ) )
    call TriggerAddAction( t, function KillDeath )
    set t = CreateTrigger()

    loop
        exitwhen i > MAX_PLAYERS
        set GiverMenu[i] = DialogCreate()
        call TriggerRegisterDialogEventBJ(t, GiverMenu[i])
        set i = i+1
    endloop
    
    call TriggerAddAction(t, function accept)
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddAction(t, function ItemAq)
    
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddAction(t, function UpdateAvailableQuests)
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SELL_ITEM)
    call TriggerAddAction(t, function KillReward)
endfunction

endlibrary

This is the demo code for the first starting quests:

JASS:
library QuestInit initializer InitQuests
    function InitQuests takes nothing returns nothing
        local QuestLib_Quest KillBoar = QuestLib_Quest.create()
        local QuestLib_Quest KillerP = QuestLib_Quest.create()
        local QuestLib_Quest PeonRevolt = QuestLib_Quest.create()
        
        call KillBoar.IntQuest(gg_unit_Ntin_0022, 1, "Bad Peasants", "ReplaceableTextures\\CommandButtons\\BTNAmbush.blp")
        call KillBoar.IntQuestItem( 'hpea', 3, "Peasants", 1)
        call KillBoar.AddRItem('bspd')
        call KillBoar.AddReward(150, 15, 0)
        call KillBoar.IntStrings(/*
        */"This is the intro!",/* 
        */"This is the Info!",/* 
        */"This is the Complete msg!",/*
        */"This is the reinfo!"/*
        */)
        
        call KillerP.IntQuest(gg_unit_Ntin_0022, 2, "Killer Peasants", "ReplaceableTextures\\CommandButtons\\BTNAmbush.blp")
        call KillerP.AddReward(100, 0, 0)
        call KillerP.IntQuestItem( 'hpea', 3, "Peasants", 1)
        call KillerP.IntQuestItem( 'ratf', 3, "Claws", 2)
        call KillerP.IntStrings(/*
        */"This is the intro!",/* 
        */"This is the Info!",/* 
        */"This is the Complete msg!",/*
        */"Mad Peasants are revolting! Please help stop the uprising of peasants before they do any damage. They peasants dwell up north of here. Good Luck and I will reward you greatly."/*
        */)
    
        call PeonRevolt.IntQuest(gg_unit_Nfir_0031, 3, "Peon Revolt", "ReplaceableTextures\\CommandButtons\\BTNAmbush.blp")
        call PeonRevolt.AddReward(500, 10, 0)
        call PeonRevolt.IntQuestItem( 'opeo', 8, "Peons", 1)
        call PeonRevolt.IntStrings(/*
        */"This is the intro!",/* 
        */"This is the Info!",/* 
        */"This is the Complete msg!",/*
        */"The Peons to the North are becoming violent, they have been stealing our pigs, please stop them at all costs!"/*
        */)
    endfunction
endlibrary
 
Status
Not open for further replies.
Top