• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Is this quest "system" fine?

Status
Not open for further replies.
Level 3
Joined
Nov 26, 2009
Messages
35
Just created this "system" for my map, there a lot of repeatable quests and i don't want to create them one by one, that's very boring. So i decided to make my life a little bit easier.
Will it work fine in MUI(Quests is intended to be for ALL players they will just gain lower rewards if they are lower/higher requirement level)?
Unit buy a item from shop(power-up) => set RepeatableQuest_id = item hp(im setting them 1,2,3,4,5 and etc hp in object editor)
Unit dies => set RepeatableQuestUnit_ID = supply used by that unit(same with items, can't use point-value because it's used in respawn system)

This is quests preset where i give all quests "stats"
  • RepeatableQuestsPresets
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- ================================================================================================================ --------
      • Set VariableSet RepeatableQuestInit = 1
      • -------- ========================WolfsQuest======================== --------
      • Set VariableSet RepeatableQuestKillCount[RepeatableQuestInit] = 0
      • Set VariableSet RepeatableQuestKillRequired[RepeatableQuestInit] = 50
      • Set VariableSet RepeatableQuestMaxLevel[RepeatableQuestInit] = 10
      • Set VariableSet RepeatableQuestMinLevel[RepeatableQuestInit] = 1
      • Set VariableSet RepeatableQuestRewardGold[RepeatableQuestInit] = 5
      • Set VariableSet RepeatableQuestRewardXP[RepeatableQuestInit] = 50
      • Set VariableSet RepeatableQuestRewardGoldNerfe[RepeatableQuestInit] = 1
      • Set VariableSet RepeatableQuestRewardXPNerfed[RepeatableQuestInit] = 5
      • Set VariableSet RepeatableQuestTitle[RepeatableQuestInit] = |cffd45e19Wolfs!
      • Set VariableSet RepeatableQuestDesc[RepeatableQuestInit] = |cffd45e19Kill 50 wolves. Reward - 100 exp, 5 gold.|r |cffff0000Max Level - 10.|r
      • Set VariableSet RepeatableQuestIconPath[RepeatableQuestInit] = ReplaceableTextures\CommandButtons\BTNTimberWolf.blp
      • -------- ================================================================================================================ --------
      • -------- ================================================================================================================ --------
      • Set VariableSet RepeatableQuestInit = (RepeatableQuestInit + 1)
      • -------- ========================GnollsQuest======================== --------
      • Set VariableSet RepeatableQuestKillCount[RepeatableQuestInit] = 0
      • Set VariableSet RepeatableQuestKillRequired[RepeatableQuestInit] = 75
      • Set VariableSet RepeatableQuestMaxLevel[RepeatableQuestInit] = 20
      • Set VariableSet RepeatableQuestMinLevel[RepeatableQuestInit] = 10
      • Set VariableSet RepeatableQuestRewardGold[RepeatableQuestInit] = 15
      • Set VariableSet RepeatableQuestRewardXP[RepeatableQuestInit] = 200
      • Set VariableSet RepeatableQuestRewardGoldNerfe[RepeatableQuestInit] = 1
      • Set VariableSet RepeatableQuestRewardXPNerfed[RepeatableQuestInit] = 5
      • Set VariableSet RepeatableQuestTitle[RepeatableQuestInit] = |cffd45e19Gnolls|R
      • Set VariableSet RepeatableQuestDesc[RepeatableQuestInit] = |cffd45e19Kill 75 gnolls.|r|n|cff00ffffReward : 200 exp, 15 gold|r. |cffff0000Min lvl - 10, Max lvl - 20 |r|r
      • Set VariableSet RepeatableQuestIconPath[RepeatableQuestInit] = ReplaceableTextures\CommandButtons\BTNGnollWarden.blp
      • -------- ================================================================================================================ --------
This is quest start/rewards

  • RepeatableQuestsStart
    • Events
      • Unit - Village Elder 0157 <gen> Sells an item (from shop)
      • Unit - Village Engineer 0085 <gen> Sells an item (from shop)
    • Conditions
      • (Item: (Sold Item)'s Integer Field: Hit Points ('ihtp')) Less than 10000
    • Actions
      • Set VariableSet RepeatableQuest_id = (Item: (Sold Item)'s Integer Field: Hit Points ('ihtp'))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RepeatableQuestBool[RepeatableQuest_id] Equal to Да
          • ((Buying unit) is A Hero) Equal to Да
          • RepeatableQuestKillCount[RepeatableQuest_id] Equal to RepeatableQuestKillRequired[RepeatableQuest_id]
        • Then - Actions
          • Quest - Destroy RepeatableQuest[RepeatableQuest_id]
          • Set VariableSet RepeatableQuestKillCount[RepeatableQuest_id] = 0
          • Set VariableSet RepeatableQuestBool[RepeatableQuest_id] = Нет
          • Sound - Play Rescue <gen>
          • Set VariableSet RepeatableQuestInt = 0
          • For each (Integer A) from 1 to PlayerAmount, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Hero level of hero[RepeatableQuestInt]) Less than or equal to RepeatableQuestMaxLevel[RepeatableQuest_id]
                  • (Hero level of hero[RepeatableQuestInt]) Greater than or equal to RepeatableQuestMinLevel[RepeatableQuest_id]
                • Then - Actions
                  • Hero - Add RepeatableQuestRewardXP[RepeatableQuest_id] experience to hero[RepeatableQuestInt], Show level-up graphics
                  • Player - Add RepeatableQuestRewardGold[RepeatableQuest_id] to (Owner of hero[RepeatableQuestInt]).Current gold
                • Else - Actions
                  • Hero - Add RepeatableQuestRewardXPNerfed[RepeatableQuest_id] experience to hero[RepeatableQuestInt], Show level-up graphics
                  • Player - Add RepeatableQuestRewardGoldNerfe[RepeatableQuest_id] to (Owner of hero[RepeatableQuestInt]).Current gold
              • Set VariableSet RepeatableQuestInt = (RepeatableQuestInt + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RepeatableQuestBool[RepeatableQuest_id] Equal to Нет
            • Then - Actions
              • Quest - Create a Optional quest titled RepeatableQuestTitle[RepeatableQuest_id] with the description RepeatableQuestDesc[RepeatableQuest_id], using icon path RepeatableQuestIconPath[RepeatableQuest_id]
              • Set VariableSet RepeatableQuestBool[RepeatableQuest_id] = Да
              • Set VariableSet RepeatableQuest[RepeatableQuest_id] = (Last created quest)
              • Sound - Play QuestNew <gen>
            • Else - Actions
And this is quests progression

  • RepeatableQuestProgress
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Player 23 (Emerald)
    • Actions
      • Set VariableSet RepeatableQuestUnit_ID = (Supply used by (Dying unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RepeatableQuestBool[RepeatableQuestUnit_ID] Equal to Да
          • RepeatableQuestKillCount[RepeatableQuestUnit_ID] Less than RepeatableQuestKillRequired[RepeatableQuestUnit_ID]
        • Then - Actions
          • Set VariableSet RepeatableQuestKillCount[RepeatableQuestUnit_ID] = (RepeatableQuestKillCount[RepeatableQuestUnit_ID] + 1)
          • Quest - Change the description of RepeatableQuest[RepeatableQuestUnit_ID] to ((RepeatableQuestDesc[RepeatableQuestUnit_ID] + |n|n|cffff0000Killed: ) + ((String(RepeatableQuestKillCount[RepeatableQuestUnit_ID])) + ((/ + (String(RepeatableQuestKillRequired[RepeatableQuestUnit_ID]))) + |r)))
        • Else - Actions
Is there any better solution than using item life or unit supply usage?
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
You should look into Hashtables. They're like 2-dimensional Arrays which solve the problem you're facing. Here's an example of a 2d array:
  • Set Variable QuestKillCount[QuestID][PlayerNumber] = 1

With 2 [Indices] in your Array, you can put both the Quest ID AND the Player Number which allows these variables to work for multiple players and multiple quests at the same time.

Unfortunately, Hashtables are a bit harder to work with due to their implementation but if you think of them as 2d Arrays it can really help. Read more here:

Regarding the Item Life/Supply Usage, that could actually help simplify things. But there is an alternative, you can Save the Quest ID to each Item-Type / Unit-Type in your Hashtable. You would create your Hashtable during Map Initialization and Save each Item-type / Unit-type to the Quest ID that they belong to. Then you can Load these values at any time. So as long as you have access to an Item / Unit, which would be the case in your above triggers where you buy an Item / Kill a unit, you can Load their Quest ID.

This gives you the ability to do something like this for your Quest Item trigger:
  • Actions
  • Set Variable PN = (Player number of (Owner of (Buying unit))
  • Set Variable Item = (Sold item)
  • Set Variable ID = Load the QuestID of the Sold item from the Hashtable
  • Set Variable QuestKillCount[ID][PN] = 0
  • Quest - Destroy RepeatableQuest[ID][PN]
  • Quest - Create a new Quest...

Or this for your Quest Kill trigger:
  • Actions
  • Set Variable PN = (Player number of (Owner of (Killing unit))
  • Set Variable Unit = (Killing unit)
  • Set Variable ID = Load the QuestID of the Dying unit from the Hashtable
  • Set Variable QuestKillCount[ID][PN] = QuestKillgCount[ID][PN] + 1

Again, 2D arrays don't exist in GUI, I just like using them as an example to explain how Hashtables work.

Your actual triggers will look more like this:
  • Actions
  • Hashtable - Save some Value as X of Y in your Hashtable
X being the CHILD key and Y being the PARENT key. The Parent/Child keys are just another way of saying X is your first [Index] and Y is your second [Index].
 
Last edited:
Level 3
Joined
Nov 26, 2009
Messages
35
Again, 2D arrays don't exist in GUI, I just like using them as an example to explain how Hashtables work.
So i created this crafting "system" :D
  • CraftList
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- =======Setup======= --------
      • Set VariableSet CraftingItems2DInt = 6
      • -------- ======================Basic Sword Upgrade====================== --------
      • Set VariableSet CraftingListInt = 1
      • Set VariableSet CraftingListInt2 = 1
      • Set VariableSet CraftingList2DArrayInt = ((CraftingListInt x CraftingItems2DInt) + CraftingListInt2)
      • -------- ===================== --------
      • Set VariableSet CraftingItemRequired[CraftingList2DArrayInt] = Basic Sword
      • Set VariableSet CraftingRequiredCharges[CraftingList2DArrayInt] = 0
      • -------- ===================== --------
      • -------- =======NextPiece======= --------
      • Set VariableSet CraftingListInt2 = (CraftingListInt2 + 1)
      • Set VariableSet CraftingList2DArrayInt = ((CraftingListInt x CraftingItems2DInt) + CraftingListInt2)
      • -------- ===================== --------
      • Set VariableSet CraftingItemRequired[CraftingList2DArrayInt] = |cff808080Wolf teeth|R
      • Set VariableSet CraftingRequiredCharges[CraftingList2DArrayInt] = 15
      • -------- ===================== --------
      • Set VariableSet CraftingItemsCountReq[CraftingListInt] = CraftingListInt2
      • Set VariableSet CraftingItemOutput[CraftingListInt] = Шлем доблести
      • -------- ===================== --------
      • -------- ======================Basic Armor Upgrade====================== --------
      • Set VariableSet CraftingListInt = (CraftingListInt + 1)
      • Set VariableSet CraftingListInt2 = 1
      • Set VariableSet CraftingList2DArrayInt = ((CraftingListInt x CraftingItems2DInt) + CraftingListInt2)
      • -------- ===================== --------
      • Set VariableSet CraftingItemRequired[CraftingList2DArrayInt] = Basic Plate Armor
      • Set VariableSet CraftingRequiredCharges[CraftingList2DArrayInt] = 0
      • -------- ===================== --------
      • -------- =======NextPiece======= --------
      • Set VariableSet CraftingListInt2 = (CraftingListInt2 + 1)
      • Set VariableSet CraftingList2DArrayInt = ((CraftingListInt x CraftingItems2DInt) + CraftingListInt2)
      • -------- ===================== --------
      • Set VariableSet CraftingItemRequired[CraftingList2DArrayInt] = |cff808080Wolf hide|r
      • Set VariableSet CraftingRequiredCharges[CraftingList2DArrayInt] = 15
      • -------- ===================== --------
      • Set VariableSet CraftingItemsCountReq[CraftingListInt] = CraftingListInt2
      • Set VariableSet CraftingItemOutput[CraftingListInt] = Доспехи-клинколомы
      • -------- ===================== --------
  • Craft
    • Events
      • Unit - Горный король 0014 <gen> Sells an item (from shop)
    • Conditions
      • (Item-class of (Sold Item)) Equal to Powerup
    • Actions
      • Set VariableSet CraftingID = (Item: (Sold Item)'s Integer Field: Hit Points ('ihtp'))
      • Set VariableSet CraftingID2D = 1
      • Set VariableSet Crafting2DArrayID = (CraftingID x CraftingItems2DInt)
      • For each (Integer A) from 1 to CraftingItemsCountReq[CraftingID], do (Actions)
        • Loop - Actions
          • Set VariableSet Crafting2DArrayID = (Crafting2DArrayID + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Buying unit) has an item of type CraftingItemRequired[Crafting2DArrayID]) Equal to Да
              • (Charges remaining in (Item carried by (Buying unit) of type CraftingItemRequired[Crafting2DArrayID])) Greater than or equal to CraftingRequiredCharges[Crafting2DArrayID]
            • Then - Actions
              • Set VariableSet CraftingID2D = (CraftingID2D + 1)
            • Else - Actions
              • Skip remaining actions
      • Set VariableSet CraftingID2D = 1
      • Set VariableSet Crafting2DArrayID = (CraftingID x CraftingItems2DInt)
      • For each (Integer A) from 1 to CraftingItemsCountReq[CraftingID], do (Actions)
        • Loop - Actions
          • Set VariableSet Crafting2DArrayID = (Crafting2DArrayID + 1)
          • Game - Display to (All players) the text: (String(Crafting2DArrayID))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CraftingRequiredCharges[Crafting2DArrayID] Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by (Buying unit) of type CraftingItemRequired[Crafting2DArrayID])
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CraftingRequiredCharges[Crafting2DArrayID] Greater than 0
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CraftingRequiredCharges[Crafting2DArrayID] Equal to (Charges remaining in (Item carried by (Buying unit) of type CraftingItemRequired[Crafting2DArrayID]))
                    • Then - Actions
                      • Item - Remove (Item carried by (Buying unit) of type CraftingItemRequired[Crafting2DArrayID])
                    • Else - Actions
                      • Item - Set charges remaining in (Item carried by (Buying unit) of type CraftingItemRequired[Crafting2DArrayID]) to ((Charges remaining in (Item carried by (Buying unit) of type CraftingItemRequired[Crafting2DArrayID])) - CraftingRequiredCharges[Crafting2DArrayID])
                • Else - Actions
      • Hero - Create CraftingItemOutput[CraftingID] and give it to (Buying unit)
First i was thinking about creating it with hashtables but can't find how to save item-type to them

I don't wanted to use hashtables for quest system because i wan't keep it as much simple as i can
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
In order to Save Unit-types and Item-types you need to first get them in their Integer form like this:
  • Actions
    • Set VariableSet ItemType = Claws of Attack +15
    • Custom script: set udg_ItemID = udg_ItemType
    • Hashtable - Save ItemID as 0 of 0 in (Last created hashtable).
ItemType is an Item-Type variable and ItemID is an Integer variable.

Using Custom script you're able to convert ItemType into it's Integer form, which you can then Save in the Hashtable as an Integer.

Then in cases where you're dealing with an Item and not an Item-type you can do this:
  • Events
    • Unit - A unit acquires an item
  • Actions
    • Set VariableSet ItemType = (Item-type of (Item being manipulated))
    • Custom script: set udg_ItemID = udg_Item
Now you can load ItemID from the Hashtable.

Anyway, do whatever works for you.
 
Status
Not open for further replies.
Top