| 05-12-2004, 01:11 AM | #1 |
Simmilar to my no bar zombies of evilness. Try this quirk out for size. Set the base hp of the unit to exactly zero. Now his HP will display 1/1 be red and his life bar will be completely empty. Simmilar circumstances exist. He is invulnerable, and his hp is oddly at 1 hp by the games consideration. Who really is scared of a guy with more hp then he can use? I'm scared of the one whose hp keeps falling deeper and deeper into defecit. |
| 05-12-2004, 01:13 AM | #2 |
Yea, it's those 1 HP bastards you gotta watch out for... They are bad mudda scrutchas |
| 05-12-2004, 01:16 AM | #3 |
I dont know how this is on topic, but interesting discovery nonetheless. More interesting would be to find why wc3 considers a guy with 0 hp infinitly powerful... Hmm, I suppose that it would be fitting that ghosts would have this property, but other than that... What happens when you set the HP of a unit to a negitive integer? Doca->Lol. (prepares for a lot of funny/wierd comments) |
| 05-12-2004, 02:39 AM | #4 |
Uhh, the game probably show's his life as 1hp because hp is a real value. If the unit does take damage and has his hp reduced below 0, the game may crash once he gets to -2^32. Not very likely, but possible :) |
| 05-12-2004, 03:03 AM | #5 |
anything below zero and he loses his lifebar. The hp is grounded at the minimal value you set, you can't heal him because hes at max hp. |
| 05-12-2004, 03:07 AM | #6 |
Hmmm... So, he can be attacked, but not die? That could be useful in cinematics where you want the unit to fight, but never actually die until you kill them. It would help avoid noth exorborantly high health values as well as heal all units triggers. This is a very interesting and potentially useful find. Good job Weeadar! |
| 05-12-2004, 03:20 AM | #7 |
Same effect as the last one... how do you come up with these anyway? |
| 05-12-2004, 03:32 AM | #8 |
It's a math trick involving rollovers/wrapping at certain values. Since WC3 cannot set a unit's life to 0, that's dead, it displays as 1. Since the life is really 0, when he takes damage his life goes negative. Likely, WC3 interprets any number of value less than or equal to 0 as a 1 when displaying. However, the true life is most likely negative. So, upon surpassing a life value of -2^31 (-2147483648) the life will either wrap to a positive integer, or crash. |
| 05-12-2004, 03:54 AM | #9 |
If that's so, if I did a call DisplayTextToPlayer() displaying the unit's life, would it return a negative value, or would it return a 1? |
| 05-12-2004, 04:36 AM | #10 |
Depends on whether or not the jass returns the integer displayed by the WC3 engine, or the integer that actually expresses the unit's life. |
| 05-12-2004, 04:41 AM | #11 |
I think it would express the actual unit's life rather than the game's display of it. I'll do a test. |
| 05-12-2004, 06:54 PM | #12 |
It expresses it as exactly 0. As far as negative hp it expresses it at 0, then if attacked the max hp the unit has. |
| 05-15-2004, 02:04 PM | #13 |
Oh, and one correction, Unit HP is actually not a integer, but a real, so there is no imediate problem with -2~31. And another piece of information, HP is a real, so whenever damage is applied, it goes "exactly" to the ammount. So you can indeed have a ability/spell/whatever that deals "0.25" damage to a unit, and it will indeed damage it by that much. Anyhow, exactly when a unit gets anywhere <1, he dies, so even if he loses too 0.99999 HP, he dies. Just a good thing to know. ~Cubasis |
| 05-15-2004, 02:46 PM | #14 |
This looks cool. Anyway was just wondering, is the intergers/real values in WC3 limited from -2^32 to 2^32 since all of us are running 32 bit computers? Back on topic, this is cool. Gotta test it out when I have time.. |
| 05-16-2004, 01:04 AM | #15 |
First, Reals work completely differently than integers. Reals can be much bigger than ints, and can have decimals, unlike ints. They store their value with Exponential and so can have much higher, and much lower (closer too zero) than int. However, as you know, INT is whole numbers, so while then a integer can store 2000000001, real can't, as it doesn't have that big of a precision, however, reals can store like 86300000000000 easily. So, yes, Integers in WC3 are limited to -2^31 - (2^31 - 1) (as they are signed, thus 31). While Reals also use 32 bit's, but use them differently. And no, the reason for this is not really becouse we run 32 big computers, it's just a more typical system. They could have, without doubt, as there is no problem with having f.ex. 64 bit integers, even C# has that at it's base as Long Int's. ~Cubasis |
