1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

GetPrimaryAttribute v2.1 (GUI)

Submitted by El Saif
This bundle is marked as substandard. It may contain bugs, not perform optimally or otherwise be in violation of the submission rules.
GetPrimaryAttribute v2.0
Created by El Saif

A very simple system i made in GUI to allow checking your hero's primary attributes and it values.

Basically, this system use an ability to check the primary attributes.
You should manually add the abilities to each hero using Object Editor.

1. 'Strength' ability for Strength hero.
2. 'Agility' ability for Agility hero.
3. 'Intelligence' ability for Intelligence hero.

How to IMPORT :

1. Delete all of the previous version of system/snippet triggers from your map, then copy 'PrimaryStat Config' and 'PrimaryStat' triggers to your map.

2. OR IF you have the v2.0++ of this snippet, just replace the JASS scripts with the new one.​

How to USE :

1. GetPrimaryAttribute : Use to check its primary attribute with :​

- PrimarySTR

- PrimaryAGI

- PrimaryINT

Example : GetPrimaryAttribute Equal to PrimarySTR (Which is hero with Strength primary attribute).​

2. GetPrimaryValueInc : Use to get the values of primary attribute with bonuses.​

3. GetPrimaryValueExc : -without bonuses.​

4. GetPrimaryString : Use to check the attribute name.​

Why i made this system is only to make coding simpler. Especially GUI Users.

Well, Critics and Advices please.


//* U P D A T E S *//

Change Log

v1.0 :
- Released​
v2.0 :
- Changes the trigger script, Convert everything to JASS.
- Using Hidden Natives instead of dummy abilities. Dummies and its variables removed as well.
- Change 'PrimaryAGI' integer value to 3 and 'PrimaryINT' to 2.
- 'PrimaryStatEnd' trigger is now included in the main trigger.
- Add a condition to check if the unit is a hero.​
v2.1 :
- Updated description a bit and add how to import properly.
- Simplified condition script on function 'PrimaryStatCondition'.
- Deleted line DestroyTrigger() within PrimaryStatEnd trigger. Both thanks to MyPad.​


By the way, very thanks to TriggerHappy !
Contents

PrimaryStat (Map)

Reviews
Dr Super Good
Comment: Although some people may find this useful it is important to note that it relies on unexposed natives functions (as of 1.30.4). Now these might be exposed in future patches but they might also be completely removed which could cause...
  1. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,243
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    5
    I would suggest a slightly-more elegant approach, involving the unit's base damage, though it relies on the gameplay constant Damage Bonus per Attribute not being equal to 0, while the native
    GetHeroPrimaryAttribute
    has not been publicly exposed. (This is based on the common.j file in 1.30.1)

    Before performing a check, let's make sure that the unit is a Hero. If not, return a default null expression of your choice.
    If the unit's type's primary stat attribute has already been obtained, just return the result from it. Otherwise, get the unit's base damage from both indices (do not assume that only 1 will ever be used). Store those, because we'll need it later.

    Now, we temporarily increment the Strength of the Hero by 1. If the current base damage is not equal to the previously stored base damage, we flag that as the main attribute. Then, with or without Strength being the main attribute, we decrement the Strength of the Hero by 1 (to counteract the addition operation earlier). Repeat with Agility and Intelligence.

    Once we get the appropriate stat attribute, we then store it in a hashtable, and return the value.
     
  2. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,609
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
  3. El Saif

    El Saif

    Joined:
    Dec 25, 2014
    Messages:
    63
    Resources:
    0
    Resources:
    0
    Really? i just realize it by now.
     
  4. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    899
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Well, rip.
    This could actually have been a potential resource.
    Looks like blizzard is one step ahead on natives :eek:
     
  5. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,243
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    5
    For a previous version

    This would have been a potentially good resource, even as a snippet. Sadly, this would require manually implementing the flags on the scale that goes up the more Heroes you have, which can be quite heavy for some. There is also the potential for it to bug when a Hero transforms into another Hero, and back.

    The ability to translate the values into something more readable is very much appreciated in this resource, as it would have made those using this understand their triggers better.

    As functional as it may be, the reasons above would prevent it from being approved.

    Status:


    • Substandard
     
    Last edited: Oct 23, 2018
  6. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,243
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    5

    Snippet Review:



    Notes:


    • In
      function PrimaryStatCondition
      within trigger
      PrimaryStat
      , the condition can be simplified so that it would only require a single line.

      Code (vJASS):

          return IsUnitType(udg_GetHeroUnit, UNIT_TYPE_HERO)
       


    • In
      function CreatePrimaryStatEnd
      within trigger
      PrimaryStat
      , you leak a
      triggeraction
      , since the invocation of
      DestroyTrigger
      does not destroy
      triggeraction
      s associated with it. Two solutions are possible, do not destroy the trigger, (recreate if trigger was manually destroyed, or convert the line, adding a
      triggeraction
      into a
      triggercondition
      .

    Status:


    • Pending
     
    Last edited: Oct 24, 2018
  7. El Saif

    El Saif

    Joined:
    Dec 25, 2014
    Messages:
    63
    Resources:
    0
    Resources:
    0
  8. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,243
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    5
    I'd say remove the
    DestroyTrigger
    call, since all the trigger does is invoke
    ResetActions
    , which would completely nullify all relevant data related to the Hero unit, and destroy the listening trigger, which would mean that you'll have to recreate the trigger again.

    For that to happen, you must create the trigger on the init function, and leave it be. Add a warning to users so that they don't accidentally destroy that.
     
  9. El Saif

    El Saif

    Joined:
    Dec 25, 2014
    Messages:
    63
    Resources:
    0
    Resources:
    0
    Ah, ok.

    EDIT :

    Updated to v2.1.
     
    Last edited: Oct 24, 2018
  10. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,260
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I am of mixed opinions about the usefulness of this. In 1.31 PTR it is fairly easy to use the new natives to look up the primary attribute of a hero unit. However that is still a PTR.
     
  11. El Saif

    El Saif

    Joined:
    Dec 25, 2014
    Messages:
    63
    Resources:
    0
    Resources:
    0
    Well, maybe that's why i won't updates this resource again. You can reject it after the new patch updated.
     
  12. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,260
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Comment:
    Although some people may find this useful it is important to note that it relies on unexposed natives functions (as of 1.30.4). Now these might be exposed in future patches but they might also be completely removed which could cause compatibility issues. As such I cannot really recommend people use this.

    In the upcoming 1.31 patch there are likely other fully exposed approaches one could use to resolve the hero primary attribute.

    The JASS coding quality itself is also a bit lacking. I do not see the purpose PrimaryStatEnd serves seeing how if the unit fed to PrimaryStat is not a hero it could implicitly reset resulting in a simpler API.