• 🏆 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 for item to give % attribute

Status
Not open for further replies.
Level 4
Joined
Feb 26, 2010
Messages
42
Hi m8s.I am making a map and i am in the final line.so i Would like. an item ability to give percentage stats attribute when a hero equips with it.For examble to make an item tha gives 10%agility to the unit that is equiped with it.Any Ideas that may work???Ty in advance
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Create an ability that gives an attribute bonus and give the ability many levels, bonus increasing by one per level. Then copy and paste spell book ability. Set minimum spells to 1. Set the attribute bonus ability into the spell book's spell list.

Disable the spell book so it won't show in user interface. You can run this at map initialization.
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Player - Disable Spell Book for (Player((Integer A)))
When you get the item, add the spell book for the unit. Then multiply the hero attribute by the percentage increase, and set the attribute bonus ability's level to the resulting level.

This way a 10% increase would mean:

+3 when attribute is 30
+3 when attribute is 39
+4 when attribute is 40

30% increase would mean:

+9 when attribute is 30
+11 when attribute is 39
+12 when attribute is 40

and so on.

When you get another item of the same type, add the current level of the attribute ability to the equation. When you lose an item, remove the ability if the level becomes 0.
 
Level 8
Joined
Dec 12, 2010
Messages
280
Another possibility.

  • ItemAgiGain
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Slippers of Agility +3
    • Actions
      • Hero - Modify Agility of (Triggering unit): Add ((Agility of (Triggering unit) (Exclude bonuses)) mod 10)
  • ItemAgiLoss
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Slippers of Agility +3
    • Actions
      • Hero - Modify Agility of (Triggering unit): Subtract ((Agility of (Triggering unit) (Exclude bonuses)) mod 10)
 
Level 4
Joined
Feb 26, 2010
Messages
42
Another possibility.

  • ItemAgiGain
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Slippers of Agility +3
    • Actions
      • Hero - Modify Agility of (Triggering unit): Add ((Agility of (Triggering unit) (Exclude bonuses)) [B][SIZE="4"]mod[/SIZE][/B] 10)
  • ItemAgiLoss
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Slippers of Agility +3
    • Actions
      • Hero - Modify Agility of (Triggering unit): Subtract ((Agility of (Triggering unit) (Exclude bonuses)) [B][SIZE="3"][SIZE="4"]mod[/SIZE][/SIZE][/B] 10)


Ty both but can you tell me what is the "MOD" command??.I want a percentage of the agility to add in the current agility


@Maker i hope i would have the knowledge to make the trigger you suggerst but i haven't
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
^Yes.

It's also worth mentioning that if you want to make the effect stack, then you have to combine the effect and do the calculation afterwards.

Let's say your str is 38 (without bonuses) and you equip 2 items that give you +10% str. Separately handled they would give 38/10 -> 3 and that times two = 6 str in total.

But when the modifier is combined, you get 38 / 5 -> 7 str in total.
 
Level 8
Joined
Dec 12, 2010
Messages
280
Ty both but can you tell me what is the "MOD" command??.I want a percentage of the agility to add in the current agility

Mod is short for modulo which is similar to division I think but rounds off.

Maker is much better at triggers than I am, he could tell you better.

But I do know that if you divide by 10 the sum will be 10%.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Modulo returns the division remainder.

For example 6 mod 3 returns 0 since 6/3 = 2 and there is no remainder. 7 mod 3 returns 1 since you can multiply 3 two times so that it does not exceed 7, and then you'd have to add one to get to 7.

Hero attribute mod 10 works like this, I'll just explain through examples:

10 mod 10 = 0
31 mod 10 = 1
39 mod 10 = 9
42 mod 10 = 2

So it won't really work in this case.
 
Level 8
Joined
Dec 12, 2010
Messages
280
Then you'd want to do this instead

  • ItemAgiGain
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Slippers of Agility +3
    • Actions
      • Hero - Modify Agility of (Triggering unit): Add ((Agility of (Triggering unit) (Exclude bonuses)) / 10)
  • ItemAgiLoss
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Slippers of Agility +3
    • Actions
      • Hero - Modify Agility of (Triggering unit): Sub ((Agility of (Triggering unit) (Exclude bonuses)) / 10)
That would give you 10% of heroes current agility
 
Level 8
Joined
Apr 8, 2009
Messages
499
@ironman47

you do realize these calculations would bug?

Example:

36 agi +10% of 36 = 39.6 (reals) or 39 (integers)

now substract that 10% again like in your triggers....

39 agi -10% of 39 = 35.1 (reals) or 35 (integers)

as you see... stat loss. think of a way to make it a bonus stat instead of changing the stats btw. (you know... the green +x to the right of the stat.)





a way of acomplishing this could be to create a stat boosting ability based on Attribute Bonus, make it show no icons and let it have... lets say 100 levels.

each level gives +1 agility more than the previous, 1/2/3/4/5/etc.etc.

when you pick up the item, give the hero manipulating the item this ability and set the level of the ability to the amount of x% boosted (save this in a integer somewhere for whenever you pick up/drop such an item)

the only problem with above mentioned solution is that it'll cause a minor freeze on the first go. (tested.)
 
Status
Not open for further replies.
Top