• Welcome to Valhalla Legends Archive.
 

War3 Statstring Parsing

Started by -Drew-, September 24, 2006, 04:27 AM

Previous topic - Next topic

-Drew-

Okay just wrote this up with some help from some other post's. If noone has it, feel free. My intention is to see if anyone sees any problem with the code. Please let me know. As for some of the values; I have the game, but i don't know each detail so im going off of what i have read.



..The parsing sub

Public Sub ParseStatString(ByVal Statstring As String, ByRef outBuf As String)
Dim Values() As String
Dim cType As String
    Select Case Left$(Statstring, 4)
   
        Case "PX3W"
            If Len(Statstring) = 4 Then
                Call strcpy(outBuf, "Warcraft III Expansion: Frozen Throne.")
                Exit Sub
            Else
                Call strcpy(outBuf, "Warcraft III Expansion: Frozen Throne, ")
                Call strcpy(outBuf, ParseW3String(Statstring, outBuf))
            End If
        Case "3RAW"
            If Len(Statstring) = 4 Then
                Call strcpy(outBuf, "Warcraft III: Reign of Chaos.")
                Exit Sub
            Else
                Call strcpy(outBuf, "Warcraft III: Reign of Chaos, ")
                Call strcpy(outBuf, ParseW3String(Statstring, outBuf))
            End If


And the Function...

Public Function ParseW3String(ByVal Stats As String, ByRef outBuf As String)
Dim BestRace As String, Tier As String, Level As String
Dim Icon As String, Values() As String, Clan As String

    Values() = Split(Mid$(Stats, 6), " ")
   
    Tier = Mid(Values(0), 1, 1)
   
    Select Case UCase(Mid$(Values(0), 2, 1))
        Case "R"
            BestRace = "Random"
           
            Select Case Tier
                Case 1: Icon = "Peon"
                Case 2: Icon = "Green Dragon Whelp"
                Case 3: Icon = "Blue Drake"
                Case 4: Icon = "Red Dragon"
                Case 5: Icon = "Deathwing"
            End Select
        Case "N"
            BestRace = "Night Elf"
           
            Select Case Tier
                Case 1: Icon = "Peon"
                Case 2: Icon = "Archer"
                Case 3: Icon = "Druid of the Claw"
                Case 4: Icon = "Priestess of the Moon"
                Case 5: Icon = "Furion Stormrage"
            End Select
        Case "O"
            BestRace = "Orc"
           
            Select Case Tier
                Case 1: Icon = "Peon"
                Case 2: Icon = "Grunt"
                Case 3: Icon = "Tauren"
                Case 4: Icon = "Farseer"
                Case 5: Icon = "Thrall"
            End Select
        Case "U"
            BestRace = "Undead"
           
            Select Case Tier
                Case 1: Icon = "Peon"
                Case 2: Icon = "Ghoul"
                Case 3: Icon = "Abomination"
                Case 4: Icon = "Lich"
                Case 5: Icon = "Tichondrius"
            End Select
        Case "H"
            BestRace = "Human"
           
            Select Case Tier
                Case 1: Icon = "Peon"
                Case 2: Icon = "Footmen"
                Case 3: Icon = "Knight"
                Case 4: Icon = "Archmage"
                Case 5: Icon = "Medivh"
            End Select
    End Select
   
    Level = Values(1)
   
    If UBound(Values) = 2 Then
        Clan = StrReverse(Values(2))
        Call sprintf(outBuf, "Tier-%s(%s), %s Icon, is level %s and with Clan %s", Tier, Icon, BestRace, Level, Clan)
    Else
        Call sprintf(outBuf, "Tier-%s(%s), %s Icon, and is level %s", Tier, Icon, BestRace, Level)
    End If
   
End Function


Thanks..

-Edit, made code perdier

Mystical

#1
Quote from: -Drew- on September 24, 2006, 04:27 AM
Okay just wrote this up with some help from some other post's.

Quote from: topaz on September 24, 2006, 05:35 AM
Anyone else get the feeling this is leeched too?

this is where the retarded-ness would begin.

*cough DUH, there's other post(s) here that have full code to the same thing, why would you even say somthing let alone say somthing so someone could post something else as useless.



Select Case Left$(Statstring, 4)
   

         Case "PX3W"
            If Len(Statstring) = 4 Then
                Call strcpy(outBuf, "Warcraft III Expansion: Frozen Throne.")
                Exit Sub
            Else
                Call strcpy(outBuf, "Warcraft III Expansion: Frozen Throne, ")
                Call strcpy(outBuf, ParseW3String(Statstring, outBuf))
            End If
       
         Case "3RAW"
            If Len(Statstring) = 4 Then
                Call strcpy(outBuf, "Warcraft III: Reign of Chaos.")
                Exit Sub
            Else
                Call strcpy(outBuf, "Warcraft III: Reign of Chaos, ")
                Call strcpy(outBuf, ParseW3String(Statstring, outBuf))
            End If



Len here looks a lil odd to me =\

-Drew-

#2
Look i really don't care to argue over this kinda of crap. I wrote the code from line 1, no copy, no pasting. Only reference i could find was this post http://forum.valhallalegends.com/index.php?topic=2984.0 and this on battle.net for the icons of each tier http://www.battle.net/war3/ladder/war3-ladder-info-laddericons.aspx?Gateway=Azeroth My Biggest question was i couldnt find anything saying there was a difference in W3XP.

If i post code that is not mine, i will say so; I don't have any issues with that.

rabbit

Yeah.  So where are the sprintf() and strcpy() functions?  You realize strcpy(str1, str2) is the same as str1 = str1 & str2?  You also leave ParseStatString() and it's switch completely unclosed.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

RealityRipple

I think he was showing a sample from that sub, not the whole thing. the whole sub is sort of public domain now. you can find it everywhere.

Some notes on it: i've noticed people just put the best race and icon into a generic statstring text, like "Best race: Human. Icon: Footman" why not do it in a more friendly way, maybe with some other info? Like so: "Human Footman (25 wins)". Just my two bits.

Warrior

Quote from: rabbit on September 24, 2006, 07:12 AM
Yeah.  So where are the sprintf() and strcpy() functions?  You realize strcpy(str1, str2) is the same as str1 = str1 & str2?  You also leave ParseStatString() and it's switch completely unclosed.

I'd think strcpy would be faster, although the speed gain is probably small.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

RealityRipple

Public Sub strcpy(ByRef Source As String, ByVal nText As String)
    Source = Source & nText
End Sub


There is no difference. I saw no use in it, so I don't use it anymore.

FrOzeN

#7
Considering the function strcpy() doesn't exist in VB6 it would be slower/faster depending on how you created it.

Assuming you just did,
Public Sub strcpy(ByRef Source As String, ByVal nText As String)
    Source = Source & nText
End Sub

Then it would be slower as you'd already be doing that exact code, except now it has to parse it through a function. If you were maybe calling it from an external .dll written in say C++ then it *may* be faster to combine the strings.

Either way, it's not going to make any noticeable difference. I'm pretty sure the code to parse WarCraft 3 strings was originally written in by C++ (and released) then someone converted it over, and just created the strcpy & sprintf functions to make the conversion easier. Since then, numerous sources codes I've looked through all seem to contain this function but no one has actually credited where it originally came from, and I'm pretty sure not every VB6 coders first thought is to create the function strcpy to combine strings.
~ FrOzeN

RealityRipple

I got my original statstring code from some old d1 bot... I then edited it alot because the war3 stuff was wrong, it didn't provide enough d2 info (like what act they're on [yes, that IS in the statstring]), and it was lacking in a lot of areas. It also now has Game Statstrings. Final result: http://realityripple.com/Uploads/modParseStats.bas

-Drew-

That's exactly what i wanted; W3XP and WAR3 do differ, noticed it in your code. I guess i didn't check the difference between xp and non-xp on the website, just found all of it.
Thanks Ripple

RealityRipple

Ya, each race got a new icon... and there's Tournament icons. I think there's links to these places in BNetDocs, but here:
WAR3 Icons: http://www.battle.net/war3/ladder/war3-ladder-info-laddericons.aspx
W3XP Icons: http://www.battle.net/war3/ladder/w3xp-ladder-info-laddericons.aspx

-Drew-

okay here's something i just noticed...


0000:  FF 0F 2C 00 01 00 00 00 00 00 00 00 4E 00 00 00   ÿ,........N...
0010:  00 00 00 00 0D F0 AD BA 0D F0 AD BA 47 65 4B 00   .....ð­º.ð­ºGeK.
0020:  50 58 33 57 20 47 50 43 57 20 30 00               PX3W GPCW 0.....

0000:  FF 0F 2F 00 01 00 00 00 00 00 00 00 0F 00 00 00   ÿ/...........
0010:  00 00 00 00 0D F0 AD BA 0D F0 AD BA 62 4C 69 6E   .....ð­º.ð­ºbLin
0020:  6B 7A 00 50 58 33 57 20 47 50 43 57 20 30 00      kz.PX3W GPCW 0..


These people both had an amlost completely different statstring. Is this more of the tournament stuff? I didn't see anything like this in your w3 parsing

My Statstring was..

0000:  FF 0F 31 00 01 00 00 00 00 00 00 00 00 00 00 00   ÿ1............
0010:  00 00 00 00 0D F0 AD BA 0D F0 AD BA 4F 78 69 4B   .....ð­º.ð­ºOxiK
0020:  6C 65 61 6E 00 33 52 41 57 20 31 4F 33 57 20 32   lean.3RAW 1O3W 2
0030:  00                                                ................




RealityRipple

Looks like they're in a clan. :)

FrOzeN

Ah, just remembered. Awhile back Darkness documented a lot of the stuff on his website. http://www.geocities.com/[email protected]/statparse.txt :)
~ FrOzeN

RealityRipple

It's a bit wrong...

Quote'================================ 9 ==================================
' Product                         | Returns
'=====================================================================
' Starcraft                       | Empty String.
' Starcraft: Brood War            | Empty String.
' Starcraft Japanese              | Empty String.
' Starcraft: Shareware            | Empty String.
' Warcraft II: Battle.net Edition | Empty String.
' Diablo                          | Returns True if it is a Diablo bot, otherwise it returns False.
' Diablo: Shareware               | Returns True if it is a Diablo: Shareware bot, otherwise it returns False.
' Diablo II                       | Empty String.
' Diablo II: Lord of Destruction  | Empty String.
' WarCraft III: Reign of Chaos    | Empty String.
' WarCraft III: The Frozen Throne | Empty String.
' Chat Bot                        | Empty String.
' Unknown                         | Empty String.
the d1 stuff. Diablo is always 0, Diablo Shareware is always 1 (it's a spawn boolean, like sc/war2's 5th number). And that d2 info is pitiful.