1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  3. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  4. We have a new contest going on right now! Join the 11th Music Contest! You are to make a Cinematic modern sound-track for this contest, so come and compete with other people for fun.
    Dismiss Notice

GetPrimaryAttribute v2.1 (GUI)

Submitted by El Saif
This bundle is marked as pending. It has not been reviewed by a staff member yet.
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
MyPad
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...
  1. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,107
    Resources:
    2
    Models:
    1
    Icons:
    1
    Resources:
    2
    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,514
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
  3. El Saif

    El Saif

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

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    677
    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,107
    Resources:
    2
    Models:
    1
    Icons:
    1
    Resources:
    2
    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,107
    Resources:
    2
    Models:
    1
    Icons:
    1
    Resources:
    2

    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:
    50
    Resources:
    0
    Resources:
    0
  8. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,107
    Resources:
    2
    Models:
    1
    Icons:
    1
    Resources:
    2
    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:
    50
    Resources:
    0
    Resources:
    0
    Ah, ok.

    EDIT :

    Updated to v2.1.
     
    Last edited: Oct 24, 2018