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

Bag System

Status
Not open for further replies.
Level 6
Joined
Dec 23, 2008
Messages
82
This bag system doesnt work right and idk why. when you have a bag in your inventory and you acquire an item, it will store the item in a hashtable where you can locate it again with the bag. when you use the bag its supposed 2 give the items that were stored, to the hero that used the bag, it just wont give the items back. PLZ HELP. thx in return and +rep
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set T97Hash = (Last created hashtable)
  • Bag Use
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Bag
    • Actions
      • Set HandleConverter = (Key (Item being manipulated))
      • For each (Integer SlotCheck) from 1 to (Load 6 of HandleConverter from T97Hash), do (Actions)
        • Loop - Actions
          • Hero - Give (Load SlotCheck of HandleConverter in T97Hash) to (Hero manipulating item)
      • Item - Set charges remaining in (Item being manipulated) to 0
      • Hashtable - Save 0 as 6 of HandleConverter in T97Hash
  • Acquire Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Not equal to Bag
    • Actions
      • For each (Integer SlotCheck) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Item-type of (Item carried by (Hero manipulating item) in slot SlotCheck)) Equal to Bag
                  • (Charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck)) Less than 5
            • Then - Actions
              • Set HandleConverter = (Key (Item carried by (Hero manipulating item) in slot SlotCheck))
              • Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck)) + 1)
              • Hashtable - Save (Charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck)) as 6 of HandleConverter in T97Hash
              • Hashtable - Save 1 as 7 of HandleConverter in T97Hash
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 7 of HandleConverter from T97Hash) Equal to 1
        • Then - Actions
          • Hashtable - Save Handle Of(Item being manipulated) as (Load 6 of HandleConverter from T97Hash) of HandleConverter in T97Hash
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Item - Hide (Last dropped item)
          • Hashtable - Save 0 as 7 of HandleConverter in T97Hash
        • Else - Actions
 
  • (Charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck)) Less than 5
This should be:
  • (Charges remaining in (Item carried by (Triggering unit) of type Tome of Experience)) Less than 5
Because the charges can also refer to other items. If you had a summoning item for example or potions with stacked charges, the trigger would count them as the charged item you are referring to, although you want this to count only Bag-type items.

  • Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot SlotCheck)) + 1)
Should be:
  • Item - Set charges remaining in (Item carried by (Triggering unit) of type Bag) to ((Charges remaining in (Item carried by (Triggering unit) of type Bag)) + 1)
  • Set HandleConverter = (Key (Item carried by (Hero manipulating item) in slot SlotCheck))
Should be:
  • Set HandleConverter = (Key (Item carried by (Triggering unit) of type Bag))
This way your unit can support multiple bags. If you want it to support only one bag at a time (suggested), then, save the items on the "Triggering unit".

  • Hero - Drop (Item being manipulated) from (Hero manipulating item)
    • Item - Hide (Last dropped item
Since you hide the item and you give it to your unit afterwards, remember to unhide it.
 
Status
Not open for further replies.
Top