1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[GUI] Basic Modifiable Item Bonuses

Discussion in '"Graveyard"' started by frettory, Oct 20, 2014.

  1. frettory

    frettory

    Joined:
    Jan 19, 2012
    Messages:
    51
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    What is this guide about/why would I need this?
    This guide is about giving items of the same type different bonuses. In other words, it teaches you how to create items with different bonuses without creating a ton of items.

    This system might be useful for people who want to create material-based crafting systems but do not want to create a ton of items for each of the possible combinations of materials.

    However, I will not teach you how to create a crafting system in this guide.
    So how do I do this?
    First of all, you should create a Hashtable. If you do not know how to create a Hashtable, just use this code:

    • Initialization
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Hashtable - Create a hashtable
        • Set Hashtable = (Last created hashtable)


    After that, you will want to save the bonuses of the items to the hashtable by adding to the previous trigger. The trigger below is how your trigger should look like after you are finished with it.

    • Initialization
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Hashtable - Create a hashtable
        • Set Hashtable = (Last created hashtable)
        • -------- Below actions not really needed --------
        • Set tempPoint = (Center of (Playable map area))
        • Item - Create Enchanted Gemstone at (tempPoint)
        • Custom script: call removeLocation(tempPoint)
        • -------- Above actions not really needed --------
        • Hashtable - Save 10 as (Key Armor Bonus) of (Key (Last created item)) in Hashtable


    Now you want to create a trigger that adds the bonuses of the item to the hero when he pick the item and another trigger that removes the bonuses of the item when the hero drops the item.

    • Item Add Bonuses
      • Events
        • Unit - A unit Acquires an item
      • Conditions
      • Actions
        • Set tempUnit = (Triggering unit)
        • Unit - Add Item Bonus Armor (+X) to (tempUnit)
        • Unit - Set level of Item Bonus Armor (+X) for (tempUnit) to ((Level of Item Bonus Armor (+X) for (tempUnit)) + (Load (Key Armor Bonus) of (Key (Item being manipulated)) from Hashtable))

    • Item Remove Bonuses
      • Events
        • Unit - A unit Loses an item
      • Conditions
      • Actions
        • Set tempUnit = (Triggering unit)
        • Unit - Set level of Item Bonus Armor (+X) for (tempUnit) to ((Level of Item Bonus Armor (+X) for (tempUnit)) - (Load (Key Armor Bonus) of (Key (Item being manipulated)) from Hashtable))


    Now all you have to do is create the 'Item Bonus' ability (Set the level 1 value to 0, increase the value by 1 every level and set the max level to 100) and you are done!
     

    Attached Files:

    Last edited: Oct 20, 2014
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,626
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Merge the two hashtable triggers. (the ones at init)

    Check if level of the ability already exist before adding it. Aka checking if level is greater than 0

    Instead of using "your item" as a variable you should use real examples since using variables in a hashtable is impossible unless you do it in JASS. Using key(your_item) wont work, in GUI wc3 only supports stuff like Key(Item Being Manipulated)

    Don't use a loop and increase the level by 1 X times, you should save the current level of the ability and save it into the hashtable.

    also use a variable for triggering unit.

    Overall it can be useful but I think it's kinda complicated compared to how simple the feature actually is. I might show the triggers myself if I am bored enough later on today.
     
    Last edited: Oct 20, 2014
  3. frettory

    frettory

    Joined:
    Jan 19, 2012
    Messages:
    51
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    #1: They are the same trigger at different stages of completion.

    #2: That will remove the MUI aspect of it.

    #3: Done.

    #4: Done.

    #5: Why? Does Triggering Unit leak now? I won't compromise MUI for a neater code.

    Oh wait. I forgot WCIII is not multithreaded.
     
  4. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,626
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    No but it's faster to use variables.
     
  5. frettory

    frettory

    Joined:
    Jan 19, 2012
    Messages:
    51
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Faster as in game speed or easier to reference?
     
  6. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,626
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    More like the processor can handle variables faster. It's no different from real programming languages.

    If you want a more indeph explaination you can just head over to google.
    >Link<

    Edit:
    No. But the thing is, your trigger in the tutorial made no sense. It seems like you're using a variable as a key which should be impossible. However in the actual map you use last created item, which makes total sense. The key was called bonus something, but it's updated now, so I am happy :p
     
    Last edited: Oct 20, 2014
  7. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    But your method is limited by +100. I mean, you can make another ability, but it isn't too efficient. You should use a binary system, e.g. +1, +2, +4, +8, +16, +32, etc. That way you can form any number with only a combination of a few abilities! For example, if you want to support any number up to 100, you only need to have 7 abilities. (1, 2, 4, 8, 16, 32, 64) This may seem like a lot, but it actually creates a much lighter load time than a single ability with 100 levels. Plus, I think widgetizer historically has had some issues with abilities with levels > 4.
     
  8. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,181
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Submission: [Basic Modifiable Item Bonuses
    Date: 22 November 2016
    Status: Graveyard
    Note:

    Tequnique is basicly to create an ability array and add them properly to the unit, dependant to an index (hash id).
    It doen't share something really new, or too useful, and one should just stick with CustomStatSystems/BonusMod approach.