• 🏆 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!

Quest items with item stacking

Status
Not open for further replies.
Level 3
Joined
Oct 22, 2010
Messages
29
I have 2 quests that involve collecting quest items. After collecting the first item it stops counting the remaining quest items as they are retrieved. I figure this is because the items are being stacked in one slot rather than taking up multiple slots in my inventory. How would I code the quest so that: a) the quest counter will still show how many items I have picked up b) make the quest complete when x amount of items are picked up and c) make the trigger that creates the quest items turn back off so that the player doesn't keep getting quest items.
I know I can make the items worth 0 but I'd really like the code to work. I'll post an example trigger for anyone that needs more info about my question.

As a matter of fact:
  • Antler Drops
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Quests[3] is enabled) Equal to True
      • (Unit-type of (Triggering unit)) Equal to Stag
    • Actions
      • Item - Create Antler at (Position of (Triggering unit))
this code is enabled but off untill this quest is taken
  • Molly
    • Events
      • Unit - A unit comes within 100.00 of Molly 0243 <gen>
    • Conditions
      • (This trigger) Equal to Molly <gen>
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Special Effect - Destroy SpecialEffects[3]
      • Quest - Display to (All players) the Quest Update message: Let's see... Add f...
      • Quest - Create a Required quest titled Antlers with the description Retrieve 10 Antlers..., using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
      • Set Quests[3] = (Last created quest)
      • Trigger - Turn on Antler Drops <gen>
      • Trigger - Turn off (This trigger)
this trigger makes the item counter work
  • Antler Quest
    • Events
      • Unit - A unit owned by Player 1 (Red) Acquires an item
    • Conditions
      • (Quests[3] is enabled) Equal to True
      • (Item-type of (Item being manipulated)) Equal to Antler
    • Actions
      • Set Antler = (Antler + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Antler Equal to 15
        • Then - Actions
          • Trigger - Turn on Antler Turn In <gen>
          • Trigger - Turn off Antler Drops <gen>
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Quest - Change the description of Quests[3] to ((Gather 15 Antlers: + (String(Antler))) + /15)
          • Quest - Display to (All players) the Quest Update message: ((Antler: + (String(Antler))) + /15)
and the turn in
  • Antler Turn In
    • Events
      • Unit - A unit owned by Player 1 (Red) Is issued an order targeting an object
    • Conditions
      • (This trigger) Equal to Molly <gen>
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • Antlers Equal to (Item being manipulated)
      • (Quests[3] is enabled) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Antler) Equal to True
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • Antler Equal to 15
        • Then - Actions
          • Hero - Give (Item being manipulated) to Molly 0243 <gen>
          • Quest - Mark Quests[3] as Completed
          • Quest - Display to (All players) the Quest Update message: Thank you, Hero! I ...
          • Player - Add 500 to Player 1 (Red) Current gold
          • Hero - Add 500 experience to (Triggering unit), Show level-up graphics
          • Trigger - Turn off (This trigger)
        • Else - Actions
The code doesn't malfunction so I put my query for the missing codes here. The code works if I make it require only 1 quest item.
 
Level 3
Joined
Oct 22, 2010
Messages
29
Hmmm, you should remove this...

(Item-type of (Item being manipulated)) Equal to Antler

if you want this...

a) the quest counter will still show how many items I have picked up

to happen, coz you are limiting your (Set Antler = (Antler + 1)
counter, if that is your counter...

~edit~
That was the original counter for when the items weren't stacking. I now have a stacking code.

So how do I set a charge counter? I have no idea.
~edit~
TY SanKakU. I will re-write the line so that is uses your suggested answer.
 
Last edited:
Level 13
Joined
May 11, 2008
Messages
1,198
i think you need an integer variable. you should be able to have in quests description string + integer + string. the integer can be the integer variable. each time you get an item, you can take away one. you might need to update the quest description, but the integer value will change after you've taken away one.

you can enable triggers and disable them. i think you want to disable the trigger giving items for quest if the quest is finished. not sure exactly how to make quests complete, but i think you did already...if you need it done after x number of items obtained, we can run check if the integer is down to 0 or not. if we are checking for this, the integer might need to be a hard number, like a player's(just anyone who isn't really playing so doesn't have resources) gold/lumber/food.

player resource might not be easiest way, though. get charge of the item might be best. it can be your integer to use for the quest. for example if you needed ten of the item... your item charge would be part of formula. 10 - item charge shows in the quests how many items you need to get.
then we check when you've got an item, it is dummy item which is used up and you then add a charge to your main item. this way every time you add the charge to the main item, you also run a check to count how many charges you now have. if you got 10, then you can end the quest. otherwise, we simply update the quest to show the new integer, which is 10(or whatever goal is) minus the item charge count.
 
Status
Not open for further replies.
Top