HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ASCII and warcraft

01-12-2007, 11:02 PM#1
Brent
Hi, is there anyone who knows how Warcraft III converts ASCII to base ten?
I'm assuming it converts to base ten, since when doing I2S on the "integer" 'A' it spits out 65, which is the base ten equivilant of that ASCII character.

however, when doing I2S on the integer 'A000', i get a very large number (I don't have world editor open at the moment, but for 4-digit ASCII codes warcraft seems to convert them to 9 - 10 digit base 10 numbers)

does anyone know how warcraft arrives at these large numbers?

i found a script by peppar that converts a single ASCII character to decimal, and I want it to work on rawcodes.
01-12-2007, 11:15 PM#2
CaptainPicard
Trying my hand at actually helping people, rather than just asking questions...

My thought is that it takes a 4-character string and converts it to an integer by multiplying the ASCII value of each character. An integer is a four-byte block, and a character is one byte. No coincidentally, 2^8 = 256 and 256^4 = 2^32 ~4,000,000,000, which is the maximum value of an unsigned integer.

But, to see if I'm correct, you should get

('A' = 65)*256^3 + ('0' = 48)*256^2 + ('0' = 48)*256 + ('0' = 48) = 1093677104

for your string 'A000'.

Now, since they're guaranteed to have certain character inputs (perhaps even alphanumeric ones) they may be doing the conversions differently, but since you say the integers are on the order of a billion, I expect they're doing it as I show above.

Capt. Picard
01-12-2007, 11:21 PM#3
Brent
Quote:
Originally Posted by CaptainPicard
Trying my hand at actually helping people, rather than just asking questions...

My thought is that it takes a 4-character string and converts it to an integer by multiplying the ASCII value of each character. An integer is a four-byte block, and a character is one byte. No coincidentally, 2^8 = 256 and 256^4 = 2^32 ~4,000,000,000, which is the maximum value of an unsigned integer.

But, to see if I'm correct, you should get

('A' = 65)*256^3 + ('0' = 48)*256^2 + ('0' = 48)*256 + ('0' = 48) = 1093677104

for your string 'A000'.

Now, since they're guaranteed to have certain character inputs (perhaps even alphanumeric ones) they may be doing the conversions differently, but since you say the integers are on the order of a billion, I expect they're doing it as I show above.

Capt. Picard
it appears that they only use the characters A-Z a-z and 0 - 9, however i've tested what you've suggested and it worked out perfectly. thanks a lot!!
01-13-2007, 03:09 AM#4
Joker
Sry for hijacking this thread, but it seems like you got your question answered. So my question is:

Is there any type of program that converts colors into ascii that wacraft can understand?
01-13-2007, 03:11 AM#5
wyrmlord
Like taking a color and converting it to a color code you mean? There's quite a few tools for that in the resources section.
01-13-2007, 03:29 AM#6
Joker
I dont see any besides vex's one with the map, but i dont want to go back and forth between maps..
01-13-2007, 05:15 AM#7
DioD
CS pools uses this
01-13-2007, 08:14 AM#8
Daelin
If you actually need a program which takes the rawcodes (base 256) from an input file and writes into an output file the base 10 number (the long one) I made something in C++. Tell me if you want this. It's not very complex but it does the trick. :)

~Daelin
01-13-2007, 11:06 AM#9
Vexorian
Quote:
Originally Posted by Joker
Sry for hijacking this thread, but it seems like you got your question answered. So my question is:

Is there any type of program that converts colors into ascii that wacraft can understand?
Colors aren't converted into ascii.

Then again I swear that programs are impractical for this, it is way better to understand how RGB and hex work then |cAARRGGBBtext|r

AA : alpha value
RR : red value
GG : green value
BB : blue value

All of these values are numbers from 0 to 255 in hexadecimal, 0 is 00 , 16 is 10 , 128 is 80 and 255 is FF.

Most of the times you use FF as alpha.

And as for the rest, the bigger the values the lighter the color and viceversa.

FF000000 is black since it got 0 for red, green and blue
FFFFFFFF is white since it got 255 for the 3 main colors
FFFF0000 is pure red
FF00FF00 is pure green
FF0000FF is pure blue.

Then mixing colors is really easy, in the computer world green+red = yellow , green+blue=teal, and red+blue = pink

So FFFFFF00 is yellow.

Then you can get tones between

FFFFFF80 is a mix between yellow and blue. Also if you increase / decrease all of the values at the same time you get lighter and darker colors. FF000030 is a dark blue and FF8080FF is a lighter blue