• 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 stat by %.. trigger

Status
Not open for further replies.
Level 4
Joined
Sep 27, 2007
Messages
85
how do i make a trigger that when a player types some thing like

-Str (then percentage) like -Str 25.

it will increase there strength by 25?

so wat type of trigger do i do so that when they type -Str (then a random number between 1 - 50 ?????) please help
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
it would be even easier if we could multiply it with 1.XX, but that can be quite complicated :D(i think)

anyhow, he wants to know how to make a Command trigger, here is what i cooked up(can be boiled better, but anyway, i think)

  • Strength Boost
  • Events
    • Player - Player 1(Red) types a chat message containing -str as A substring
  • Conditions
    • (Integer((Substring((Entered chat string), 6, 7))))) Less than 51
  • Actions
    • Hero - Modify Strength of (whatever hero you want) : Add (Integer(((Real((Strength of (same hero) (Exclude bonuses)))) x ((Real((Substring((Entered chat string), 6, 7)))) / 100.00)))))
the substring function will check what letters there are between the letter # of the chat string. Wow, that was badly explained, here is a better example

Player 1 types -Hell yeah!

Substring((Entered chat string), 2, 7) will then become "Hell ya" since "H" is the second letter in the (Entered chat string) and "a" is the seventh letter in the (Entered chat string)
 
Level 17
Joined
Apr 13, 2008
Messages
1,608
it would be even easier if we could multiply it with 1.XX, but that can be quite complicated :D(i think)
You are right but some people don't understand why would you multiply it by 1.XX, I thought that dividing first by 100 would make more sense to them.

For some reason I thought that he knew about that event and the string operations, meh, I think it was silly for me to think that, sorry and you are right.
 
Level 4
Joined
Sep 27, 2007
Messages
85
im really confsed i dont really understand a thing your talking about

whats this? -(Entered chat string), 6, 7)))))

I dont understand this... Add (Integer(((Real((Strength of (same hero) (Exclude bonuses)))) x ((Real((Substring((Entered chat string), 6, 7)))) / 100.00)))))

whats with all the brackets
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
I dont understand this... Add ((Integer((Real((Strength of (same hero) (Exclude bonuses)))) x ((Real((Substring((Entered chat string), 6, 7)))) / 100.00)))))

whats with all the brackets
all those brackets are a part of one big calculation

Since Attributes are Integers, and Percent calculations are better done with Real values, i decided to convert a whole Real calculation into Integer(hence why it begins with (Integer to show that the final value is an Integer and not a Real). The function is Conversion - Convert Real to Integer

Secondly, since its a calculation, im going to need a Arithmetic function(is found at the top of the functions list when using Reals and Integers)

In the first of the two values of the Arithmetic function, I wanted the Current Strength of the Hero to be stored, but since its an Integer Value, im going to need another Conversion(since we are using Real values to calculate with), so in the first value of the Arithmetic function you are going to need a Conversion - Convert Integer to Real

In this Converison - Convert Integer to Real, simply go to Hero - Hero Attribute, and there we are reached the final settings of the first Arithmetic value

Now here comes the tricky part. Since you wanted the Chat Command to be able to increase the Strength depending on what number was used in the Chat Command, we must use a Substring(which, as emperor_d3st already explained) and divide it by 100(since we need the multiplication to be in percent and not in a full value)

So, in the second value of the Arithmetic function, simply put in another Arithmetic function, and in the first of this one, you need the complicated Substring thingy

which starts with a Conversion - Convert String to Real, and now, since we want what the player wrote after -Str, we are going to need to use a Substring. Now, while we are here, i can explain it better this time.

Substring((Entered chat string), 2, 7) will become (Str 25)
Substring((Entered chat string), 3, 6) will become (tr 2)
Substring((Entered chat string), 4, 5) will become (r )
Substring((Entered chat string), 1, 8) will become (-Str 25 )

you understand? the 2 numbers decide what letters(and all in between them) that will be used as a String instead of the whole of (Entered chat string)

now, as you have chosed Conversion - Convert String to Real, locate the Substring function at the top. In there, you choose the first value to be Event Response - Entered chat string, and the numbers to by 6 and 7

now, we still have the second value of the second Arithmetic function left, but that is the easiest one. Simply put in 100.00

To simplyfy things, here is how the calculation would look with variables
A x (B / 100)
A = The amount of Strength your Hero has
B = The number the player put after -Str

And a simplyfied verison of how to manage this in the Trigger Editor
Hero - Modify Attribute
--Strength
--YourHero(whatever hero you want)
--Add
--Converion - Convert Real to Integer
----Arithmetic( x in the middle)
------Conversion - Convert Integer to Real
--------Hero - Hero Attribute
----------Strength
----------YourHero
----------Exclude bonuses
------Arithmetic( / in the middle)
--------Conversion - Convert String to Real
----------Substring
------------Event Response - Entered chat string
------------6
------------7
--------100.00
 
Status
Not open for further replies.
Top