• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Hero - Modify attribute function

Status
Not open for further replies.
Level 10
Joined
Mar 16, 2009
Messages
354
When using the Hero - Modify attribute trigger the result shows that the stats are being functionally changed, by looking at the increased health, mana, damage, however the number identifiers for the actual stats remain constant.

Is there a way to use the Hero - Modify attribute function and have the value of the stat in the UI changed?

Original Stats
1.jpg


After Acquiring Item (+6 Intelligence, +20% Intelligence (Excluding Bonus))
2.jpg


The base intelligence 19 multiplied by 20% is 3.8, since stats are integers 3 intelligence should be added. And judging by the mana and damage increase it was but the actual stat remains the same. And it gets a bonus +2 to damage and +1 to base damage, whats up with that?

I do not believe it has anything to do with the triggers of adding the effect to the hero when acquiring the item or removing them when discarding, but if you think seeing the triggers would help I will post them.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
JASS:
native SetHeroAgi takes unit whichHero,integer newAgi,boolean permanent returns nothing
native SetHeroInt takes unit whichHero,integer newInt,boolean permanent returns nothing
native SetHeroStr takes unit whichHero,integer newStr,boolean permanent returns nothing
Try altering the permanent flag to see if it makes a difference.

It might also be you have just discovered a new WC3 bug where adding hero stats in response to an item aquisition event causes some big messup.

In any case triggers and the map would be useful (or atleast a map which demonstrates this problem).
 
Level 10
Joined
Mar 16, 2009
Messages
354
I am not really a triggerer, or much of a good mapper, but I usually make terrains, so I have no clue what the Jass script means or what the permanent flag is, but heres the triggers


  • Events
    • Unit - A unit Acquires an item
  • Conditions
    • Item[(Player number of (Triggering player))] Not equal to (Item being manipulated)
  • Actions
    • -------- Vars --------
    • Set Item[(Player number of (Triggering player))] = (Item being manipulated)
    • Set ItemType[(Player number of (Triggering player))] = (Item-type of Item[(Player number of (Triggering player))])
    • Set Hero[(Player number of (Triggering player))] = (Hero manipulating item)
    • -------- Test Doubles --------
    • Hero - Drop Item[(Player number of (Triggering player))] from Hero[(Player number of (Triggering player))]
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Hero[(Player number of (Triggering player))] has an item of type ItemType[(Player number of (Triggering player))]) Equal to False
      • Then - Actions
        • -------- Replace and Do effects --------
        • Hero - Give Item[(Player number of (Triggering player))] to Hero[(Player number of (Triggering player))]
        • Set Item[(Player number of (Triggering player))] = (Last created item)
      • Else - Actions
        • -------- Replace and no effects --------
        • Hero - Give Item[(Player number of (Triggering player))] to Hero[(Player number of (Triggering player))]
        • Skip remaining actions
    • -------- Apply Bonuses --------
    • -------- Strength [5%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Gauntlets of Strength + 4 [5%]
      • Then - Actions
        • Set Attribute = (Real((Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.05)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Strength [10%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Gauntlets of Strength 2 + 7 [10%]
      • Then - Actions
        • Set Attribute = (Real((Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.10)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Strength [20%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Belt of Power + 10 [20%]
      • Then - Actions
        • Set Attribute = (Real((Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.20)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Intelligence [5%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Mantle of Intelligence + 4 [5%]
      • Then - Actions
        • Set Attribute = (Real((Intelligence of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.05)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Inteligence [10%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Mantle of Intelligence + 7 [10%]
      • Then - Actions
        • Set Attribute = (Real((Intelligence of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.10)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Intelligence [20%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Robe of Clarity + 10 [20%]
      • Then - Actions
        • Set Attribute = (Real((Intelligence of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.20)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Agility [5%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Slippers of Agility + 4 [5%]
      • Then - Actions
        • Set Attribute = (Real((Agility of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.05)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Agility [10%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Slippers of Agility + 7 [10%]
      • Then - Actions
        • Set Attribute = (Real((Agility of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.10)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • -------- Agility [20%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Boots of Dexterity + 10 [20%]
      • Then - Actions
        • Set Attribute = (Real((Agility of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.20)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Add IntAttribute
      • Else - Actions
    • Trigger - Run Store Items <gen> (checking conditions)


  • Events
    • Unit - A unit Loses an item
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • DroppableItem[(Player number of (Triggering player))] Equal to (Item being manipulated)
        • DroppableItem2[(Player number of (Triggering player))] Equal to (Item being manipulated)
        • DroppableItem3[(Player number of (Triggering player))] Equal to (Item being manipulated)
        • DroppableItem4[(Player number of (Triggering player))] Equal to (Item being manipulated)
        • DroppableItem5[(Player number of (Triggering player))] Equal to (Item being manipulated)
        • DroppableItem6[(Player number of (Triggering player))] Equal to (Item being manipulated)
  • Actions
    • -------- Vars --------
    • Set Item[(Player number of (Triggering player))] = (Item being manipulated)
    • Set ItemType[(Player number of (Triggering player))] = (Item-type of Item[(Player number of (Triggering player))])
    • Set Hero[(Player number of (Triggering player))] = (Hero manipulating item)
    • -------- Test Doubles --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Hero[(Player number of (Triggering player))] has an item of type ItemType[(Player number of (Triggering player))]) Equal to True
      • Then - Actions
        • Skip remaining actions
      • Else - Actions
    • -------- Remove Bonuses --------
    • -------- Strength [5%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Gauntlets of Strength + 4 [5%]
      • Then - Actions
        • Set Attribute = (Real((Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.05)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Set to (Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))
      • Else - Actions
    • -------- Strength [10%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Gauntlets of Strength 2 + 7 [10%]
      • Then - Actions
        • Set Attribute = (Real((Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.10)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Strength [20%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Belt of Power + 10 [20%]
      • Then - Actions
        • Set Attribute = (Real((Strength of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.20)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Intelligence [5%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Mantle of Intelligence + 4 [5%]
      • Then - Actions
        • Set Attribute = (Real((Intelligence of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.05)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Inteligence [10%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Mantle of Intelligence + 7 [10%]
      • Then - Actions
        • Set Attribute = (Real((Intelligence of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.10)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Intelligence [20%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Robe of Clarity + 10 [20%]
      • Then - Actions
        • Set Attribute = (Real((Intelligence of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.20)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Agility [5%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Slippers of Agility + 4 [5%]
      • Then - Actions
        • Set Attribute = (Real((Agility of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.05)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Agility [10%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Slippers of Agility + 7 [10%]
      • Then - Actions
        • Set Attribute = (Real((Agility of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.10)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • -------- Agility [20%] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of Item[(Player number of (Triggering player))]) Equal to Boots of Dexterity + 10 [20%]
      • Then - Actions
        • Set Attribute = (Real((Agility of Hero[(Player number of (Triggering player))] (Exclude bonuses))))
        • Set ConvertedAttribute = (Attribute x 0.20)
        • Set IntAttribute = (Integer(ConvertedAttribute))
        • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Subtract IntAttribute
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • DroppableItem[(Player number of (Triggering player))] Equal to (Item being manipulated)
      • Then - Actions
        • Set DroppableItem[(Player number of (Triggering player))] = Cheese 0078 <gen>
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DroppableItem2[(Player number of (Triggering player))] Equal to (Item being manipulated)
          • Then - Actions
            • Set DroppableItem2[(Player number of (Triggering player))] = Cheese 0078 <gen>
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • DroppableItem3[(Player number of (Triggering player))] Equal to (Item being manipulated)
              • Then - Actions
                • Set DroppableItem3[(Player number of (Triggering player))] = Cheese 0078 <gen>
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • DroppableItem4[(Player number of (Triggering player))] Equal to (Item being manipulated)
                  • Then - Actions
                    • Set DroppableItem4[(Player number of (Triggering player))] = Cheese 0078 <gen>
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • DroppableItem5[(Player number of (Triggering player))] Equal to (Item being manipulated)
                      • Then - Actions
                        • Set DroppableItem5[(Player number of (Triggering player))] = Cheese 0078 <gen>
                      • Else - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • DroppableItem6[(Player number of (Triggering player))] Equal to (Item being manipulated)
                          • Then - Actions
                            • Set DroppableItem6[(Player number of (Triggering player))] = Cheese 0078 <gen>
                          • Else - Actions


  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • DroppableItem[(Player number of (Triggering player))] Equal to Cheese 0078 <gen>
      • Then - Actions
        • Set DroppableItem[(Player number of (Triggering player))] = (Item being manipulated)
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DroppableItem2[(Player number of (Triggering player))] Equal to Cheese 0078 <gen>
          • Then - Actions
            • Set DroppableItem2[(Player number of (Triggering player))] = (Item being manipulated)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • DroppableItem3[(Player number of (Triggering player))] Equal to Cheese 0078 <gen>
              • Then - Actions
                • Set DroppableItem3[(Player number of (Triggering player))] = (Item being manipulated)
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • DroppableItem4[(Player number of (Triggering player))] Equal to Cheese 0078 <gen>
                  • Then - Actions
                    • Set DroppableItem4[(Player number of (Triggering player))] = (Item being manipulated)
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • DroppableItem5[(Player number of (Triggering player))] Equal to Cheese 0078 <gen>
                      • Then - Actions
                        • Set DroppableItem5[(Player number of (Triggering player))] = (Item being manipulated)
                      • Else - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • DroppableItem6[(Player number of (Triggering player))] Equal to Cheese 0078 <gen>
                          • Then - Actions
                            • Set DroppableItem6[(Player number of (Triggering player))] = (Item being manipulated)
                          • Else - Actions


Probably really leaky and around the bush triggers that could be completed in a more simple way, but oh well I'm new to triggering so live and learn. If you can even understand the sloppy mess you deserve a cookie :)
 
Last edited:
Level 8
Joined
Dec 9, 2009
Messages
397
Use the trigger command
JASS:
[TRIGGER][/TRIGGER]

(I Put it in jass so it would show the command)

Put your triggers between those so we can see how they are set up, they all look in-line right now.
 
Level 8
Joined
Dec 9, 2009
Messages
397
you used the jass commands, use the trigger commands, I put them in the jass box so they would show up.

In your item drop trigger, there isn't really a need to set the item type, unit, and item to variables
and if you want to set them to variables, don't use an array variable.

and really have no clue as to what your conditions would mean.
 
Level 10
Joined
Mar 16, 2009
Messages
354
Thanks but thats not really what this thread was about. I don't know what I made all of those variables and arrays, I guess I wanted to make sure that the system was MPI, I am not a triggerer and I figured since many players units would be picking up and dropping items I might as well just do it, it's not like there is really a downside to not doing it; preemptive problem solving xP

The conditions were to make it so that the players can have more then 1 of the items that buff by percentage, but only one of the percentages of the same amount will apply. And because the first trigger is initialized by obtaining an item I had to prevent an infinite loop, because the only way to check for doubles I found was to remove the item obtained check if an item of the same type is still present and then replace it. This also trips the losing an item event for the second trigger so I had to store the values from the first trigger, which are the items in the inventory and then make sure that the dropped item is one of the stored ones, not just the same type. So that is what I tried to do, hope that helps you figure out the stat problem.
 
Level 8
Joined
Dec 9, 2009
Messages
397
The downside is your making it really confusing, and longer to create. only 1 trigger runs at a time and so as long as you have no waits, if you need an integer used in a trigger, you can use the same tempint variable for every single trigger in your map.

Are you able to use more than 1 type of stat increasing item at a time? ( like 2 that adjust int)


One problem I see is, if the stats are being added but not shown.

If you have 100 str, and you get an item that increases it by 25%

You'd get 125str

when you unequip it, you lose the 25% bonus, but with the new str of 125, 25% = 30

You would end up with 95 str
 
Level 8
Joined
Dec 9, 2009
Messages
397
The easy way to check the item % bonus value is change the item levels of the items
level 5 for 5%
level 25 for 25%

(Hold shift and click on the item level in the editor to change it to a higher number than allowed)

----------------------EDIT----------------------
Everything works now, and is much simplified, EXCEPT: removing the stat doesn't seem to work and I'm not sure if you can remove stats that were added. Another method could be 50 levels of a skill that increases str by 1 per lvl, and add that skill for the level of bonus to the unit as well. Though, I don't think the levels past 1 work for item skills that add stats, so would have to be 50 item skills, that give +1 - +50 str and set them to an ability array and then assign the strskill[Bonusnumber] to the unit.

Here is the map: (Map in game list has "-Edited" after it)
http://www.hiveworkshop.com/forums/pastebin_data/79l8mg/_files/Projectx.w3x

  • Obtained Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiple ConditionsOr - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to (==) Gauntlets of Strength + 4 [5%]
              • (Item-type of (Item being manipulated)) Equal to (==) Gauntlets of Strength 2 + 7 [10%]
              • (Item-type of (Item being manipulated)) Equal to (==) Belt of Power + 10 [20%]
        • Then - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • stritem[(Player number of (Owner of (Hero manipulating item)))] Not equal to (!=) No item
              • (Item level of (Item being manipulated)) Greater than (>) (Item level of stritem[(Player number of (Owner of (Hero manipulating item)))])
            • Then - Actions
              • Hero - Modify Strength of (Hero manipulating item): Subtract strbonus[(Player number of (Owner of (Hero manipulating item)))]
              • Set TempReal = ((Real((Item level of (Item being manipulated)))) / 100.00)
              • Set TempReal = ((Real((Strength of (Hero manipulating item) (Exclude bonuses)))) x TempReal)
              • Set Tempint = (Integer(TempReal))
              • Set strbonus[(Player number of (Owner of (Hero manipulating item)))] = Tempint
              • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Add Tempint
              • Set stritem[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)
            • Else - Actions
              • Set TempReal = ((Real((Item level of (Item being manipulated)))) / 100.00)
              • Set TempReal = ((Real((Strength of (Hero manipulating item) (Exclude bonuses)))) x TempReal)
              • Set Tempint = (Integer(TempReal))
              • Set strbonus[(Player number of (Owner of (Hero manipulating item)))] = Tempint
              • Hero - Modify Strength of (Hero manipulating item): Add Tempint
              • Set stritem[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)
        • Else - Actions
  • Dropped Item
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) (Item-type of stritem[(Player number of (Owner of (Hero manipulating item)))])
        • Then - Actions
          • Hero - Modify Strength of (Hero manipulating item): Subtract strbonus[(Player number of (Owner of (Hero manipulating item)))]
          • Set Tempint = 0
            • Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
              • Loop - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Multiple ConditionsOr - Any (Conditions) are true
                      • Conditions
                        • (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (==) Gauntlets of Strength + 4 [5%]
                        • (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (==) Gauntlets of Strength 2 + 7 [10%]
                        • (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to (==) Belt of Power + 10 [20%]
                  • Then - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Tempint Less than (<) (Item level of (Item carried by (Hero manipulating item) in slot (Integer A)))
                      • Then - Actions
                        • Set Tempint = (Item level of (Item carried by (Hero manipulating item) in slot (Integer A)))
                        • Set stritem[(Player number of (Owner of (Hero manipulating item)))] = (Item carried by (Hero manipulating item) in slot (Integer A))
                      • Else - Actions
                  • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Tempint Equal to (==) 0
              • Then - Actions
                • Set strbonus[(Player number of (Owner of (Hero manipulating item)))] = 0
                • Set stritem[(Player number of (Owner of (Hero manipulating item)))] = No item
              • Else - Actions
                • Set TempReal = ((Real(Tempint)) / 100.00)
                • Set TempReal = ((Real((Strength of (Hero manipulating item) (Exclude bonuses)))) x TempReal)
                • Set Tempint = (Integer(TempReal))
                • Set strbonus[(Player number of (Owner of (Hero manipulating item)))] = Tempint
                • Hero - Modify Strength of (Hero manipulating item): Add Tempint
        • Else - Actions
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Here's an alternative.


  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set ht = (Last created hashtable)
      • -------- -------------------------------------------------- --------
      • Set it = +3 +20% [STR]
      • Custom script: call SaveInteger(udg_ht, udg_it, 0, bj_HEROSTAT_STR)
      • Custom script: call SaveReal(udg_ht, udg_it, 1, 0.2)
      • -------- -------------------------------------------------- --------
      • Set it = +6 + 40% [STR]
      • Custom script: call SaveInteger(udg_ht, udg_it, 0, bj_HEROSTAT_STR)
      • Custom script: call SaveReal(udg_ht, udg_it, 1, 0.4)
      • -------- -------------------------------------------------- --------
      • Set it = +3 +10% [AGI]
      • Custom script: call SaveInteger(udg_ht, udg_it, 0, bj_HEROSTAT_AGI)
      • Custom script: call SaveReal(udg_ht, udg_it, 1, 0.1)
      • -------- -------------------------------------------------- --------
      • Set it = +4 +100% [INT]
      • Custom script: call SaveInteger(udg_ht, udg_it, 0, bj_HEROSTAT_INT)
      • Custom script: call SaveReal(udg_ht, udg_it, 1, 1.0)
  • Get
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set it = (Item-type of (Item being manipulated))
      • Custom script: if HaveSavedInteger(udg_ht, udg_it, 0) then
      • Set u = (Triggering unit)
      • Custom script: set udg_ID = GetHandleId(udg_u)
      • -------- Load stat type --------
      • Custom script: set udg_i1 = LoadInteger(udg_ht, udg_it, 0)
      • -------- Get unit str bonus --------
      • Custom script: set udg_i2 = LoadInteger(udg_ht, udg_ID, 0)
      • -------- Get Hero Attribute --------
      • Custom script: set udg_i3 = GetHeroStatBJ(udg_i1, udg_u, false)
      • -------- Get bonus of item --------
      • Custom script: set udg_i4 = R2I((udg_i3 - udg_i2 ) * LoadReal(udg_ht, udg_it, 1))
      • -------- Save bonus of item --------
      • Custom script: call SaveInteger(udg_ht, GetHandleId(GetManipulatedItem()), 0, udg_i4)
      • -------- Set new attribute value --------
      • Custom script: call SetHeroStat(udg_u, udg_i1, udg_i3 + udg_i4)
      • -------- Save new bonus --------
      • Custom script: call SaveInteger(udg_ht, udg_ID, udg_i2 + udg_i4, 0)
      • Custom script: endif
  • Lose
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Set it = (Item-type of (Item being manipulated))
      • Custom script: if HaveSavedInteger(udg_ht, udg_it, 0) then
      • Set u = (Triggering unit)
      • Custom script: set udg_ID = GetHandleId(udg_u)
      • -------- Load stat type --------
      • Custom script: set udg_i1 = LoadInteger(udg_ht, udg_it, 0)
      • -------- Get unit str bonus --------
      • Custom script: set udg_i2 = LoadInteger(udg_ht, udg_ID, 0)
      • -------- Get Hero Attribute --------
      • Custom script: set udg_i3 = GetHeroStatBJ(udg_i1, udg_u, false)
      • -------- Get bonus of item --------
      • Custom script: set udg_i4 = LoadInteger(udg_ht, GetHandleId(GetManipulatedItem()), 0)
      • -------- Set new attribute value --------
      • Custom script: call SetHeroStat(udg_u, udg_i1, udg_i3 - udg_i4)
      • -------- Save new bonus --------
      • Custom script: call SaveInteger(udg_ht, udg_ID, udg_i2 - udg_i4, 0)
      • -------- Flush hastable for the item --------
      • Custom script: call FlushChildHashtable(udg_ht, GetHandleId(GetManipulatedItem()))
      • Custom script: endif


In the init trigger, initialize all item types you need. Set the it variable to the item type. Set the herostat to the correct stat. In the SaveReal line, adjust the last number. It is the multiplier. 1.0 = 100%, 0.1 = 10% and so on.

The bonus stat is always calculated based on the unit's base attribute, not including item bonuses. Also, as the values are treated as integers, if one item gave +2.6 and another 2.4, you still get +4 and not +5. I don't feel like changing that right now :)

Pastebin link
 
Level 8
Joined
Dec 9, 2009
Messages
397
Did you want 1 item % bonus per stat, or 1 per character?

What I made tries to remove the stat if:
1 they get a better % bonus item, it removes the old and adds the new.
2 they drop the item that was giving them the current bonus, so it removes that bonus and searches the inventory for another item of that type and applies that bonus.

but the removal of the stat wasn't working.
(I only made the trigger for STR and showed how to edit for others)
 
Status
Not open for further replies.
Top