Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Spell] Hero Bag System?

Discussion in 'World Editor Help Zone' started by Knight of Arsford, Apr 2, 2020.

  1. Knight of Arsford

    Knight of Arsford

    Joined:
    Jan 28, 2015
    Messages:
    116
    Resources:
    0
    Resources:
    0
    I was looking at the Spells section for something like this but they were either too complicated for my map or just not what I was looking for.

    The idea is simple and you might know of it already: An invisible hero that acts as a bag or inventory for the main hero. I suppose it goes anywhere the main hero goes as you can swap items with it anytime anywhere.

    Any help with how to start it, or simply linking an existing Spell for it would be appreciated.
     
  2. Veritas 117

    Veritas 117

    Joined:
    Nov 17, 2010
    Messages:
    1,233
    Resources:
    0
    Resources:
    0
    It’s basically just like you said. Make a hero and give it no model file. Give it the ability called inventory (unit) that is modified to have 6 slots. Make sure it is not a hero inventory so the bag can’t use any of the items. It might be a good idea to give it invulnerability too. I set the selection size to -1.00 so the health bar would disappear. Now you just run a periodic trigger that sets a point at the position of your hero, moves the bag to that point and then make sure to destroy that point to avoid leaks. Every 1 second or so should be enough.
    I also added a trigger that runs whenever you select the bag. If you have your hero/heroes selected also it deselects the bag. That’s just so I don’t have them both selected when I drag-select my heroes.
    The last thing I did for mine was to add a trigger that detects when the bag is issued an order to pick up an item. I just make sure the bag moves to that item so I don’t have to worry about it not being in range. You won’t need it if you only have one hero though. I can attach the triggers next time I’m on my computer. I’m on my phone right now.
     
  3. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    2,383
    Resources:
    0
    Resources:
    0
    Here's something I threw together.

    The Inventory unit is hidden by default, but the Hero has an ability that hides/unhides it and moves it to his position.

    Then whenever you order your Hero to pick up an item, I check if his inventory is full, and if it is full then I order the Hero to cast a hidden ability on the target item.

    Once this ability goes off I give the target item of the ability to your Inventory unit instead. This is useful because it makes your Hero walk up and "pick up" items even when his Inventory is full.

    Note that it's designed to only work for 1 Hero per player. It would need to be expanded upon to work for multiple heroes per player. And the Inventory Unit could be designed to be a Hero as well. Also, I didn't bother dealing with the Memory Leaks but it's not that big of a deal.
    • Inventory Setup
      • Events
        • Time - Elapsed game time is 0.00 seconds
      • Conditions
      • Actions
        • -------- Setup Hero --------
        • Unit - Create 1 Hero for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
        • Unit - Add Toggle Inventory to (Last created unit)
        • Unit - Add Pick Up Item to (Last created unit)
        • -------- --------
        • -------- Setup Inventory Unit --------
        • Player Group - Pick every player in (All players) and do (Actions)
          • Loop - Actions
            • Unit - Create 1 Inventory for (Picked player) at (Center of (Playable map area)) facing Default building facing degrees
            • Set VariableSet Player_Inventory[(Player number of (Picked player))] = (Last created unit)
            • Unit - Make (Last created unit) Invulnerable
            • Unit - Hide (Last created unit)

    • Order Pick Up Item
      • Events
        • Unit - A unit Is issued an order targeting an object
      • Conditions
        • ((Triggering unit) is A Hero) Equal to True
        • (Target item of issued order) Not equal to No item
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of items carried by (Triggering unit)) Equal to 6
          • Then - Actions
            • Trigger - Turn off Order Pick Up Item <gen>
            • -------- --------
            • -------- Save the Item and order the Hero to cast our hidden Pick Up Item ability on it --------
            • Set VariableSet Player_TargetItem[(Player number of (Triggering player))] = (Target item of issued order)
            • Custom script: call IssueTargetItemOrder( GetTriggerUnit(), "unsummon", GetOrderTargetItem() )
            • -------- --------
            • Trigger - Turn on Order Pick Up Item <gen>
          • Else - Actions

    • Cast Pick Up Item
      • Events
        • Unit - A unit Begins casting an ability
      • Conditions
        • (Ability being cast) Equal to Pick Up Item
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of items carried by (Triggering unit)) Less than 6
          • Then - Actions
            • Hero - Give Player_TargetItem[(Player number of (Triggering player))] to (Triggering unit)
          • Else - Actions
            • Hero - Give Player_TargetItem[(Player number of (Triggering player))] to Player_Inventory[(Player number of (Triggering player))]
        • -------- --------
        • Unit - Order (Triggering unit) to Stop.

    • Toggle Inventory
      • Events
        • Unit - A unit Begins casting an ability
      • Conditions
        • (Ability being cast) Equal to Toggle Inventory
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player_Inventory[(Player number of (Triggering player))] is hidden) Equal to True
          • Then - Actions
            • Unit - Unhide Player_Inventory[(Player number of (Triggering player))]
            • Unit - Move Player_Inventory[(Player number of (Triggering player))] instantly to (Position of (Triggering unit))
            • Selection - Add Player_Inventory[(Player number of (Triggering player))] to selection for (Triggering player)
          • Else - Actions
            • Unit - Hide Player_Inventory[(Player number of (Triggering player))]
        • -------- --------
        • Unit - Order (Triggering unit) to Stop.
     

    Attached Files:

    Last edited: Apr 3, 2020
  4. Knight of Arsford

    Knight of Arsford

    Joined:
    Jan 28, 2015
    Messages:
    116
    Resources:
    0
    Resources:
    0
    Thanks for all your insights! I've managed to do one based on your explanations.