(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > Submissions

Submissions Submit JASS resources! If approved, they will be moved to their proper section.
Please read me first.

Reply
 
LinkBack Thread Tools Display Modes
Old 11-17-2007, 07:02 PM   #1 (permalink)

User
 
Join Date: Nov 2007
Posts: 24

Brisemec has little to show at this moment (6)


Save system that does not requires writing down codes

I have developed a system for RPG maps that generates color-coded text that can be read (from the screenshot) by a program, thus avoiding the need to write the code manually.

The JASS code, as well as the decoding program can be found here. This page contains more informations about the program and the script.



Anyways I post the JASS code here:

function CharCode takes string char returns integer
    local string charTable = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTIVWXYZ- "
    local integer currentIndex = 1
    local integer endIndex = 64

    loop
        exitwhen currentIndex > endIndex

        if SubStringBJ(charTable, currentIndex, currentIndex) == char then
            return currentIndex - 1
        endif

        set currentIndex = currentIndex + 1
    endloop

    // This is invalid
    return -1
endfunction

function EncodeChar takes integer charCode returns string
    local integer base = 3
    local string array colors
    local string result

    set colors[0] = "|c00ff0000I" // Red
    set colors[1] = "|c0000ff00I" // Green
    set colors[2] = "|c000000ffI" // Blue

    set result = colors[charCode - (charCode / base * base)]
    set charCode = charCode / base

    set result = colors[charCode - (charCode / base * base)] + result
    set charCode = charCode / base

    set result = colors[charCode - (charCode / base * base)] + result
    set charCode = charCode / base

    set result = colors[charCode] + result

    return result
endfunction

function EncodeString takes string text returns string
    local string result = ""
    local integer currentChar
    local integer currentIndex
    local integer endIndex

    set currentIndex = 1
    set endIndex = StringLength(text)
    loop
        exitwhen currentIndex > endIndex

        set currentChar = CharCode(SubStringBJ(text, currentIndex, currentIndex))
        set result = result + EncodeChar(currentChar)

        set currentIndex = currentIndex + 1
    endloop

    return result
endfunction
Brisemec is offline   Reply With Quote
Old 11-18-2007, 08:53 PM   #2 (permalink)
Model & Tutorial Moderator
 
Pyritie's Avatar

 
Join Date: Nov 2006
Posts: 7,328

Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)

Super Donor: This user has donated at least $100 to The Hive. Hero Contest #1 Winner: Slatie 

How does the program work?
Pyritie is offline   Reply With Quote
Old 11-19-2007, 10:46 AM   #3 (permalink)

User
 
Join Date: Nov 2007
Posts: 24

Brisemec has little to show at this moment (6)


Each character in the save code is encoded with four colored 'I's. Each 'I' is either red, green or blue. The program looks at the screenshot and converts each group of four 'I's into the corresponding character, then copies the resulting text to the clipboard.
Brisemec is offline   Reply With Quote
Old 11-19-2007, 11:34 AM   #4 (permalink)
Model & Tutorial Moderator
 
Pyritie's Avatar

 
Join Date: Nov 2006
Posts: 7,328

Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)

Super Donor: This user has donated at least $100 to The Hive. Hero Contest #1 Winner: Slatie 

Sounds neat. Could you show an example?
Pyritie is offline   Reply With Quote
Old 11-19-2007, 07:17 PM   #5 (permalink)

User
 
Join Date: Nov 2007
Posts: 24

Brisemec has little to show at this moment (6)


I have an example on the project's web page. Anyways, this is a screenshot of the code F34t-2dt5-3T2c-EurZ-ryTq-vg4n-v04S-q2eh-Hm4h-v, encoded with my method:

Brisemec is offline   Reply With Quote
Old 11-19-2007, 07:37 PM   #6 (permalink)
Model & Tutorial Moderator
 
Pyritie's Avatar

 
Join Date: Nov 2006
Posts: 7,328

Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)

Super Donor: This user has donated at least $100 to The Hive. Hero Contest #1 Winner: Slatie 

Sounds very complicated. Yet awesome.
Pyritie is offline   Reply With Quote
Old 11-20-2007, 01:10 AM   #7 (permalink)

User
 
Join Date: Nov 2007
Posts: 24

Brisemec has little to show at this moment (6)


It may seem complicated, but it is really simple to add this to a map. And of course, I am willing to help anybody that is interested in this system
Brisemec is offline   Reply With Quote
Old 11-20-2007, 09:48 PM   #8 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

I should have a chance to test this and review the code soon enough (blah, almost dinner right now), but it looks great! (But it would kind've suck for the average BNetter, so there are two sides to this. I suppose you could also include the classic method)

Hmm.. that would be a good system idea if you don't already have it. Have an option to display the 'real' code for people who don't have this program.

Also, just an idea, couldn't you encode the ASCII with a single color channel, and thus have 3 letters per I? (I haven't messed with too much color shiz in programming, but I don't see why not)

I suppose it would make the JASS longer (making the hex), but I see it as an advantage... (Well, maybe not SO much, since there's not any reading done by the user.. However, it would certainly be handy for long codes)
PurplePoot is offline   Reply With Quote
Old 11-20-2007, 10:24 PM   #9 (permalink)

User
 
Join Date: Nov 2007
Posts: 24

Brisemec has little to show at this moment (6)


You are right. I choose to use only three colors to minimize the chances to have decoding errors. If you look closely at a screenshot, especially at low resolution, like 640x480 or 800x600, you will notice that the letters are blended. That means that color of the letters is a mix between the text color and the background.
I could probably use more colors and still avoid such problems, but I prefer to err on the safe side. By the way, I think the current encoding is enough for any save code I have ever encountered.
Brisemec is offline   Reply With Quote
Old 11-21-2007, 01:30 AM   #10 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Use SubString instead of SubStringBJ, with -1 on the start index; it's faster.

And the program crashes for me, and yes I have the right .NET framework (or at least the one you link to) (does it have to be taken in cinematic mode? I displayed mine with DisplayTextToPlayer)
PurplePoot is offline   Reply With Quote
Old 11-21-2007, 01:44 AM   #11 (permalink)

User
 
Join Date: Nov 2007
Posts: 24

Brisemec has little to show at this moment (6)


Thanks for the advice.

You need to display the text in cinematics mode because when you do that, the text always appears at the same position, which simplifies the program. I plan to add code to detect the position of the code, but right now it has to be done like that.

About the crash, what resolution is your screenshot? I only included support for 640x480, 800x600 and 1024x768 because my computer supports only these modes. If that is the problem, if you provide-me a screenshot at the resolution you use, I will update the configuration of the program to make it support it.

I can see I really need to add code that detects the code's location...
Brisemec is offline   Reply With Quote
Old 11-21-2007, 02:00 AM   #12 (permalink)
 
Turtles's Avatar

Jessi° ♥
 
Join Date: Aug 2007
Posts: 190

Turtles is on a distinguished road (83)Turtles is on a distinguished road (83)


This sounds genius, but very impractical. it would be fairly good for a game that is already popular and to have it switch to this new system, but there are several flaws...
. If you accidently copy text or take another screenshot before decoding it, you lose all your progress...
. If you crash during alt-tabbing (which happens to a lot of people w/ wc3) its very possible for the screenshot to corrupt.
. 90% of B Net players are idiots. (~95% of all percentage statistics are made up on the spot). its very possible that they will be far too stupid to figure out how to work their Prnt Scrn button on their keyboard, much less paste it in a prog.
. Macs dont have the Prnt Scrn func, instead they have a different form of screenies. Or so Ive heard. Never used a mac myself, filthy little things.
__________________
Quote:
Originally Posted by Jen
Jessi if I was a lesbian, and you were older... oh baby ;]
Turtles is offline   Reply With Quote
Old 11-21-2007, 02:34 AM   #13 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Quote:
If you crash during alt-tabbing (which happens to a lot of people w/ wc3) its very possible for the screenshot to corrupt.
That would happen anyways.

Quote:
90% of B Net players are idiots. (~95% of all percentage statistics are made up on the spot). its very possible that they will be far too stupid to figure out how to work their Prnt Scrn button on their keyboard, much less paste it in a prog.
Which is why you would include both ways in a map.

Quote:
Macs dont have the Prnt Scrn func, instead they have a different form of screenies. Or so Ive heard. Never used a mac myself, filthy little things.
This is written for windows-only anyways.

Quote:
If you accidently copy text or take another screenshot before decoding it, you lose all your progress...
What?

Oh, and the attached screenshot crashes it.
http://www.hiveworkshop.com/forums/a...1&d=1195612470
PurplePoot is offline   Reply With Quote
Old 11-21-2007, 02:47 AM   #14 (permalink)
 
Turtles's Avatar

Jessi° ♥
 
Join Date: Aug 2007
Posts: 190

Turtles is on a distinguished road (83)Turtles is on a distinguished road (83)


Quote:
Originally Posted by PurplePoot View Post
What?
Print Screen saves an image to the Clipboard. So does highlighting text and doing CTRL+C. You can only save one image/text selection in the clipboard at a time, so the old one is overwritten if you copy something.
Turtles is offline   Reply With Quote
Old 11-21-2007, 08:43 AM   #15 (permalink)
Model & Tutorial Moderator
 
Pyritie's Avatar

 
Join Date: Nov 2006
Posts: 7,328

Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)Pyritie has much of which to be proud (1028)

Super Donor: This user has donated at least $100 to The Hive. Hero Contest #1 Winner: Slatie 

Pressing PrntScrn in wc3 automatically saves it as a file in %Root\Warcraft III\Screenshots\. No pasting in MS Paint necessary!
Pyritie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump