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

GetPrimaryAttribute v2.1 (GUI)

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: Wrda
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 *//


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...
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.
 

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:

Snippet Review:


Notes:

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

    JASS:
        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 triggeractions 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:
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.
 
Level 5
Joined
Dec 25, 2014
Messages
111
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.
Ah, ok.

EDIT :

Updated to v2.1.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
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.

 
Top