• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Primary Attribute Trigger

Status
Not open for further replies.
Level 4
Joined
Aug 19, 2004
Messages
68
I'm working on my footmen war and I wanna have a trigger that detects the primary attribute of the killing hero and gives them +1 to that attribute. Does anyone know if this can be done in GUI or do I have to resort to Jass to get this done?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Well not to be unhelpfull or anything but that sounds awfully imbalenced since it will make the player to kill the first few heroes rigged since the more they kill the strogner they become and this in return will make them win. Also it will rig all AGI heroes since the more kills they make the faster they attack and the more damage they do as well as the more armor they have so maybe you should reconsider using such a system or having it as a option since you might find it will make certian heroes rigged (play with or lose).

Well anyway
There are 2 ways to handle this since sadly there is no native function that returns the prime atribute.

1. The Table Retreive
This requires you to store a integer that can be retrieved by imputting a unit type. So from your hero you can fetch a number which you can then convert into a prime atribute type and thus add it to the hero. The number 0 could represent str, 1 agi and 2 int. This is a complex method but works fine.

2. The Logical Deduction
This method basicly compairs all the heroes stats (str, agi and int) with each other and then finds which one is the largest. The largest one it takes to be the prime atribute and so you have your prime atribute to add to. Only flaw, sadly MAJOR, with this method is that if your heroes prime atribute IS NOT the highest it will return incorrectly and so will bug since it relies on the prime atribute always gaining faster than the other atributes.

Overall I recomend method 1 since it is the only way to be 100% sure it will return right. If you are sure that the prime atribute will always be the highest stat for ALL your heroes use method 2 since it is then more efficent.
 
Level 6
Joined
Jan 27, 2007
Messages
208
hmm, check this out

Unit - Entering Playable Area
Condition - Entering Unit is [Skeleton King]
Action
Set variable STR Attribute(Player numbers of owner of entering unit)] = 1


Then,
Unit - Dies
Condition - STR Attribute (Player numbers of owner of killing unit) = 1
Action
Add 1 Str to killing unit
 
Level 8
Joined
Sep 13, 2006
Messages
431
hmm, check this out

Unit - Entering Playable Area
Condition - Entering Unit is [Skeleton King]
Action
Set variable STR Attribute(Player numbers of owner of entering unit)] = 1


Then,
Unit - Dies
Condition - STR Attribute (Player numbers of owner of killing unit) = 1
Action
Add 1 Str to killing unit

Maybe I'm just being dumb, but I don't see how this will help much... The Doctor's solutions were adequate in my opinion.
 
Level 3
Joined
May 28, 2005
Messages
47
hmm, check this out
  • Unit - Entering Playable Area
  • Condition - Entering Unit is [Skeleton King]
  • Action
  • Set variable STR Attribute(Player numbers of owner of entering unit)] = 1
  • Then,
  • Unit - Dies
  • Condition - STR Attribute (Player numbers of owner of killing unit) = 1
  • Action
  • Add 1 Str to killing unit

Wait. That will work, but it will give +1 to someone killing ANYTHING. not just heroes. This way is easier since you won't have to preset it for EACH AND EVERY HERO. Though for this way the units primary attribute will have to be the largest at level 1.

  • Melee Initialization
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Strength of (Triggering unit) (Exclude bonuses)) Greater than (Agility of (Triggering unit) (Exclude bonuses))
          • Or - Any (Conditions) are true
            • Conditions
              • (Strength of (Triggering unit) (Exclude bonuses)) Greater than (Intelligence of (Triggering unit) (Exclude bonuses))
        • Then - Actions
          • Unit Group - Add (Triggering unit) to STR_GROUP
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Agility of (Triggering unit) (Exclude bonuses)) Greater than (Strength of (Triggering unit) (Exclude bonuses))
              • Or - Any (Conditions) are true
                • Conditions
                  • (Agility of (Triggering unit) (Exclude bonuses)) Greater than (Intelligence of (Triggering unit) (Exclude bonuses))
            • Then - Actions
              • Unit Group - Add (Triggering unit) to AGI_GROUP
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Intelligence of (Triggering unit) (Exclude bonuses)) Greater than (Strength of (Triggering unit) (Exclude bonuses))
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Intelligence of (Triggering unit) (Exclude bonuses)) Greater than (Agility of (Triggering unit) (Exclude bonuses))
                • Then - Actions
                  • Unit Group - Add (Triggering unit) to INTEL_GROUP
                • Else - Actions
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Killing unit) Equal to (Random unit from STR_GROUP)
        • Then - Actions
          • Hero - Modify Strength of (Triggering unit): Add 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Killing unit) Equal to (Random unit from AGI_GROUP)
            • Then - Actions
              • Hero - Modify Agility of (Triggering unit): Add 1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Killing unit) Equal to (Random unit from INTEL_GROUP)
                • Then - Actions
                  • Hero - Modify Intelligence of (Triggering unit): Add 1
                • Else - Actions
You might need to add another trigger that will check if the killing unit/killed unit is a hero or just a regular unit.
 
Last edited:
Level 3
Joined
Jan 31, 2007
Messages
34
hmm, check this out

Unit - Entering Playable Area
Condition - Entering Unit is [Skeleton King]
Action
Set variable STR Attribute(Player numbers of owner of entering unit)] = 1


Then,
Unit - Dies
Condition - STR Attribute (Player numbers of owner of killing unit) = 1
Action
Add 1 Str to killing unit

This means that you set the primary attribute with a variable when you create a hero and in the future you add attribute points based on that var. For example "Skeleton King"'s primary attribute is agility then the varible "STR Attribute" with the index of the owning player of the unit is set to 1 and in the next trigger when a unit dies and the variable for that player is equal to 1 then the agility of the killing hero is raised by 1 and if that variable is for instance 2 then stregth is increased. The big problem is that you have to copy the trigger and replace "[Skeleton King]" for every hero in your map. Atleast this method is good but the trigger itself isn't. The events, conditions and actions in the first trigger aren't set right and are complicated to say the least the second part is good though.
 
Level 8
Joined
Sep 13, 2006
Messages
431
Yeah, you right, though I was thinking more along the lines of operator's trigger. Assuming that primary attribute was highest of all attributes, you could also use:

  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Strength of (Killing unit) (Exclude bonuses)) Greater than (Agility of (Killing unit) (Exclude bonuses))
        • (Strength of (Killing unit) (Exclude bonuses)) Greater than (Intelligence of (Killing unit) (Exclude bonuses))
      • Then - Actions
        • Hero - Modify Strength of (Killing unit): Add 1
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Agility of (Killing unit) (Exclude bonuses)) Greater than (Strength of (Killing unit) (Exclude bonuses))
            • (Agility of (Killing unit) (Exclude bonuses)) Greater than (Intelligence of (Killing unit) (Exclude bonuses))
          • Then - Actions
            • Hero - Modify Agility of (Killing unit): Add 1
          • Else - Actions
            • Hero - Modify Intelligence of (Killing unit): Add 1
...of course, adding own conditions etc.
That would at least limit to one trigger...
 
Last edited:
Level 3
Joined
Jan 31, 2007
Messages
34
Yeah, but still unit editing will be required to make sure that the heros' primary attribute is with the highest value which is still better than making a trigger for every single hero.
 
Level 3
Joined
May 28, 2005
Messages
47
Yeah, you right, though I was thinking more along the lines of operator's trigger. Assuming that primary attribute was highest of all attributes, you could also use:

  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Strength of (Killing unit) (Exclude bonuses)) Greater than (Agility of (Killing unit) (Exclude bonuses))
        • (Strength of (Killing unit) (Exclude bonuses)) Greater than (Intelligence of (Killing unit) (Exclude bonuses))
      • Then - Actions
        • Hero - Modify Strength of (Killing unit): Add 1
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Agility of (Killing unit) (Exclude bonuses)) Greater than (Strength of (Killing unit) (Exclude bonuses))
            • (Agility of (Killing unit) (Exclude bonuses)) Greater than (Intelligence of (Killing unit) (Exclude bonuses))
          • Then - Actions
            • Hero - Modify Agility of (Killing unit): Add 1
          • Else - Actions
            • Hero - Modify Intelligence of (Killing unit): Add 1
...of course, adding own conditions etc.
That would at least limit to one trigger...

This would not work if during some time in the gameplay the unit got a higher secondary attribute than his/her primary. Then the secondary attribute would go higher. My trigger doesn't take long. You just copy and paste most of the stuff and edit a bit, and it's done. Plus it's not buggy (I think) so it's overall better in the end.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Basicaly for the most accuracy use my method 1 idea.
Make a game-cache and store the atributes under the hero ID number (unit type) and when a hero is killed, it uses the player's hero type and fetches the atribute type from the game cache.
I used a simlar method to store infomation for a map I was thinking of making where I used the unit's type to return a integer which could be used with a global to retrieve infomation concerning that type.
It works well but might lag if handle vars are overused but I dought that will be the case in your map.
 
Level 8
Joined
Sep 13, 2006
Messages
431
This would not work if during some time in the gameplay the unit got a higher secondary attribute than his/her primary. Then the secondary attribute would go higher. My trigger doesn't take long. You just copy and paste most of the stuff and edit a bit, and it's done. Plus it's not buggy (I think) so it's overall better in the end.

I guess it all depends on the type of map you are making/using. In typical maps (where you can't buy attribute-boosting items and where primary starts and levels higher than secondary), my solution is quick and easy and is entirely bug-less. Plus, it needs absolutely no editing, disregarding any conditions that one may want to add. Your trigger is effective though...
 
Status
Not open for further replies.
Top