• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Turning in items at npc

Status
Not open for further replies.
Level 7
Joined
Dec 5, 2013
Messages
280
How to create neutral npc which can be given items by both players? After turning in certain number of items NPC should reward player with item or unlock purchaseable unit from neutral shop.
 
Level 7
Joined
Dec 5, 2013
Messages
280
NPC should have the repeatable quest for both players, and both player should get their own shop.
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
It depends on the interface you use for NPC interaction. For turning in items I dynamically create a dialog button, which if pressed, attempts to gather the requisite items from the player's inventory. When he has turned X in, he finishes that part of the quest.

JASS:
function itemGiveByTypeMain takes nothing returns boolean
    local player p = GetTriggerPlayer()
    local integer pid = GetPlayerId(p)
    local integer currQuest = 0
    local integer currQuestStage = 0
    local integer questRange = 0
    local integer goalBttn = 0
    local integer goalNpc = 0
    local integer goalDialog = 0
    local integer i = 0
    local integer count = 0 //how many items of the type the player has
    loop
        exitwhen questRange == TOTAL_QUESTS
        set currQuest = playerDatum[pid].findQuestByGoalType(ITEM_TYPE_GIVE_GOAL, questRange)
        set currQuestStage = playerDatum[pid].quests[currQuest].stage
        if currQuest >= 0 then
            set goalBttn = playerDatum[pid].quests[currQuest].goals[currQuestStage].goalBttn
            set goalNpc = playerDatum[pid].quests[currQuest].goals[currQuestStage].goalNpc
            set goalDialog = playerDatum[pid].quests[currQuest].goals[currQuestStage].goalDialog
            if GetClickedButton() == playerDatum[pid].npcs[goalNpc].dialogBttns[(goalDialog * MAX_DIALOGS) + goalBttn] then
                loop
                    exitwhen i == MAX_ITEMS
                    if GetItemTypeId(UnitItemInSlot(playerDatum[pid].pc.u, i)) == playerDatum[pid].quests[currQuest].goals[currQuestStage].goalItemType then
                        if playerDatum[pid].quests[currQuest].goals[currQuestStage].quant > 0 then
                            set count = count + 1
                            call RemoveItem(UnitItemInSlot(playerDatum[pid].pc.u, i))
                            set playerDatum[pid].quests[currQuest].goals[currQuestStage].quant = playerDatum[pid].quests[currQuest].goals[currQuestStage].quant - 1
                        endif
                    endif
                    set i = i + 1
                endloop
                if playerDatum[pid].quests[currQuest].goals[currQuestStage].quant == 0 then
                    call playerDatum[pid].quests[currQuest].advance()
                    call DestroyTrigger(GetTriggeringTrigger())
                endif
                set questRange = TOTAL_QUESTS
            else
                set questRange = currQuest + 1 //advance the quest counter, in case another quest has a button click goal
            endif
        else //currQuest == -1, there are no enabled quests with an item obtain goal
            set questRange = TOTAL_QUESTS
        endif
    endloop
    set p = null
    return false
endfunction
...

and then you can basically just call this for an arbitrary item and item number

JASS:
    set i = playerDatum[0].quests[1].addGoal("Give 3 Mask of Deaths to the farmer", ITEM_TYPE_GIVE_GOAL)
    call playerDatum[0].quests[1].goals[i].setGiveItemByTypeGoal('modt', 3, Farmer.index, INTRO, TAKE_BTTN)
 
Level 7
Joined
Dec 5, 2013
Messages
280
I need GUI trigger and it should be short and simple so I can understand it so I can build it myself.

I just need system where unit has repeatable quest where both players can give certain item to NPC and once 10 items have been given to the NPC, NPC rewards players individually with option to purchase item or hero which also must be summoned at special summoning area.
 
Status
Not open for further replies.
Top