• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] Minor Trigger Problem

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,610
Hey, I need your help just a little.

How do I do with triggers this calculation:

X = X + ( Every 10th level of Y hero x 1 )


Examples:

1) X is 5. Hero's level is 5. => 5 + ( 0 x 1 ) = 5
2) X is 10. Hero's level is 55. => 10 + ( 5 x 1 ) = 15
3) X is 15. Hero's level is 99. => 15 + ( 9 x 1 ) = 24
4) X is 100. Hero's level is 100. => 100 + ( 100 x 1 ) = 200


Can you tell me how do I do this? Give me an already done trigger so it's easier for me. Thanks and rep will be given to one who helps me.
 
1) I can't give much of an information because there are no information. All I can give you is this:

- I don't want decimal numbers
- I have only this done for now:
  • Set DIG_POWER = (DIG_POWER + (0 x 1))
If I put just: Hero lvl / 10, it gives decimal numbers or "roundings". I don't want decimal numbers or "roundings".

2) Don't understand what you are saying. Thanks for the help anyway...
 
WC3 has two types of numerical data. Reals and integers. Reals can represent most useful real values with a precision of up to 6 decimals.
Integers on the other hand cant represent real values. Integers can represent every number from -(2^31) to (2^31)-1.
Integers are a subset of reals, in other words every integer is also a real. You can perform mathematical operations on both of them, and even mix them.
But division is the only operation where when you divide two integers, the result can be a real value, ie a value not representable through integers. In that case, the result gets automatically rounded down to the nearest integer.

Example:
4/5 equals 0
9/5 equals 1
99/100 still equals 0
and 999/1000 also equals 0

If you want to round values in GUI, you have to convert back and forth between reals and integers. In this case, converting the result of Hero Level/10 to integer and back to real will do the trick of eliminating all decimals and rounding down to the nearest integer.
 
Yea, and I want integers. The numbers that we are counting right here will go to multiboard and I don't want any decimal numbers in there. The description says like this and I would like to do it that way:

- Phodom has this skill as a primary Profession meaning he will gain one extra point per 10 level.

Maximum level in the game is 100.

So, is this even possible to do or what?
 
  • Set Real = (Real + (((Real((Hero level of (Triggering unit)))) / 10.00) x 1.00))
You can use: Conversion - Convert Integer to Real and vice verse in your actions next to display this real variable as real or integer!

You can also show organized real with only 1, 2 or 10 numbers after .
Example: 1.0; 1.00; 1.000000000
With this: Conversion - Convert Real to Organized String

Explore conversions a little...
 
2.)Are you aware that integer division always rounds to the floor?
No, I wasn't, I figured you'd have to use a floor function or something like that that I've heard of in other places, but without that bit of knowledge I couldn't have figured this out either :pir:

  • Set Real = (Real + (((Real((Hero level of (Triggering unit)))) / 10.00) x 1.00))
You can use: Conversion - Convert Integer to Real and vice verse in your actions next to display this real variable as real or integer!

You can also show organized real with only 1, 2 or 10 numbers after .
Example: 1.0; 1.00; 1.000000000
With this: Conversion - Convert Real to Organized String

Explore conversions a little...
Hmm, the wise part of me sees the usefulness of letting the OP play around with this a little as per your advice, but the helpful/show-offy side of me wants to show how easy this is by doing it for him... unfortunately, I guess I can't help the OP (more than you already have, Kobas) without doing this part of the coding for him, and he won't always have other people to ask about for this stuff. I must commend you on the advice though, Kobas, masterfully written :pir:
 
Status
Not open for further replies.
Back
Top