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

Increase attribute by percent

Status
Not open for further replies.
Level 31
Joined
Jun 27, 2008
Messages
2,557
Hello.

Is there a way how to increase hero's attribute by percent? For example, item increase total agility by 30%. So that with every gain and loss of agility, item automatically adapt to that 30% increase of an attribute.

I tried using attribute item spell with many levels and seting its level, but it would always stay at level 1.

Thanks.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
You can modify hero's base attribute (= the white one, not the bonus green one from abilities/items) via triggers.
It would require you to store his base attribute values beforehand and then use the action Hero - Modify hero attribute and add 0,3 * (attribute of hero with bonuses) to scale the bonus with hero's items.

Edit:
Like this:
  • Hero - Modify Strength of Your_Unit: Add (Integer((0.30 x (Real((Strength of Your_Unit (Include bonuses)))))))

Problem may be when your hero levels up - if you have many hero types with scaling attributes, it would require you to create a list at map ini that saves start attributes and attribute increment per level of each hero type and then use equation [start attribute] + ( [Attribute increment] * [hero's level] )
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Strength
    • Actions
      • Hero - Modify Strength of (Hero manipulating item): Add (30 / 100)
How about this? Not sure yet though.
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
I'm confused :( Could you explain it a little bit more?
For example.

Agility: 70 +30

I acquire item1, that increase my agility by 30%. So the result would be an addition of 30.

Agility with item1: 100 +30

Then I acquire item2 that increase my agility by 100.

Agility with item1 and then acquiring item2: 100 +130

This is is already wrong. In order to make stats right, I must drop item1 and pick it up again with item2 in my inventory, then:

Agility with two items after retaking item1: 130 +130

It means I would have to retake item in case my agility change while I already have item1.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
The problem is that you will never have 200 agility, but 100 + 130, because item stat bonuses are the green ones.

Anyway that's why I wrote that if you use that trigger action, you have to save his base stats.

e.g.
0 items
Base agi: 50 - you save that into variable, let's call that variable simply AGI_var

You acquire boots of agility ( + 10 agility) so you have:
50 +10

Now you acquire item that increases your agility attribute by 20%:
You set base agi to AGI_var and as next action you add the 20% bonus:
  • Hero - Modify Agility of Your_Unit: Set to AGI_var
  • Hero - Modify Agility of Your_Unit: Add (Integer((0.30 x (Real((Agility of Your_Unit (Include bonuses)))))))
This will always reset his white attributes to their default value and then add the % bonus. You can make this fire every time he picks any item (or item from your specified list)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Yeah but you add 0,3 strength, however attributes are integer numbers, they don't have decimals, so when it's converted into integer, the decimal part is cut off (unless WCIII uses reals for attributes, but shows them as integer in game)

In fact, it does.

In the Object Editor you can set reals values to Heroes stat gain per level. if you add 1.25 per level you'll find you have 5 by lvl 4. (1.25 * 4 = 5)
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Imo, I think in object editor those are reals to give you more variety in the attribute increment, but when it's given to hero, it is converted into integer.

The same example with 1.25 per level
In level 3 it would be 1.25 * 3 => 3.75 => 3
At level 4 it would be 1.25 * 4 => 5
 
Status
Not open for further replies.
Top