huldu Posted February 28, 2006 Author Posted February 28, 2006 That UBound is really nice, in a for loop for example it will check thru an array until it reach the last input in the array? I just got another question. How do you add arrays? for example to do simple math and you would like to add all arrays to get a total. For example say you have an array, $Array[0] = 1, $Array[1] = 1, $Array[2] = 1.. and so on, would how i do to "add them up" to get a total of all the saved values in the array? "I'm paper, rock is fine, nerf scissors!!!"
neogia Posted March 1, 2006 Posted March 1, 2006 This should get you started, put in about 3 hours on it. Just change the filename to wherever the chat is located and wherever you want the test.log stored. If you have any questions on why I did what, just let me know, I gotta go to work now. It runs through your "chat.log" in about 10 seconds as it is implemented now. As you gather more and more data, it will take longer to parse, but not much longer. expandcollapse popup#include <Array.au3> Opt("TrayIconDebug", 1) ;Info arrays Dim $sSpellCount[1] $sSpellCount[0] = "init" Dim $sDmgMax Dim $sDmgCount Dim $sDmgDeflected Dim $sDmgCrit Dim $sMobDmgMax Dim $sMobDmgCount Dim $sMobDmgDeflected Dim $sExp[2] Dim $sLootMoney[3] Dim $sMobs[1] $sMobs[0] = "init" $file = FileOpen(@DesktopDir & "\Stringparser\chat.log", 0) $test = FileReadLine($file) While Not StringInStr($test, "*** Chat Log Closed") $aCast = StringRegExp($test, "\[([0-9:]*?)\] You cast a (.*?) Spell!", 1) If IsArray($aCast) Then $notFound = 1 For $i = 0 To UBound($sSpellCount)-1 $tmp = $sSpellCount[$i] If IsArray($tmp) Then If $tmp[0] == $aCast[1] Then $tmp[1] += 1 $sSpellCount[$i] = $tmp $notFound = 0 EndIf EndIf Next If $notFound == 1 Then If UBound($sSpellCount) >= 1 And $sSpellCount[0] <> "init" Then ReDim $sSpellCount[UBound($sSpellCount)+1] EndIf Dim $tmp[2] $tmp[0] = $aCast[1] $tmp[1] = 1 $sSpellCount[UBound($sSpellCount)-1] = $tmp EndIf EndIf $aBlocked = StringRegExp($test, "\[([0-9:]*?)\] ([a-zA-Z ]*?) attacks you and you (.*?) the blow!", 1) If IsArray($aBlocked) Then EndIf $aTarget = StringRegExp($test, "\[([0-9:]*?)\] You enter combat mode and target \[the (.*?)\]", 1) If IsArray($aTarget) Then EndIf $aPerformSkill = StringRegExp($test, "\[([0-9:]*?)\] You perform your (.*?) perfectly. \(+(.*?)\)", 1) If IsArray($aPerformSkill) Then EndIf $aAttack = StringRegExp($test, "\[([0-9:]*?)\] You attack ([a-zA-Z ]*?) with your .*? and hit for (.*?) \((.*?)\) damage!", 1) If IsArray($aAttack) Then If $aAttack[2] > $sDmgMax Then $sDmgMax = $aAttack[2] EndIf $sDmgCount += $aAttack[2] $sDmgDeflected += $aAttack[3] EndIf $aMiss = StringRegExp($test, "\[([0-9:]*?)\] You miss!", 1) If IsArray($aMiss) Then EndIf $aMobMiss = StringRegExp($test, "\[([0-9:]*?)\] ([a-zA-Z ]*?) attacks you and misses!", 1) If IsArray($aMobMiss) Then EndIf $aCrit = StringRegExp($test, "\[([0-9:]*?)\] You critical hit for an additional (.*?) damage!", 1) If IsArray($aCrit) Then $sDmgCrit += $aCrit[1] EndIf $aHeal = StringRegExp($test, "\[([0-9:]*?)\] You heal yourself for (.*?) hit points.", 1) If IsArray($aHeal) Then EndIf $aMobDies = StringRegExp($test, "\[([0-9:]*?)\] ([a-zA-Z ]*?) dies!", 1) If IsArray($aMobDies) Then $notFound = 1 For $i = 0 To UBound($sMobs)-1 $tmp = $sMobs[$i] If IsArray($tmp) Then If $tmp[0] == $aMobDies[1] Then $tmp[1] += 1 $sMobs[$i] = $tmp $notFound = 0 EndIf EndIf Next If $notFound == 1 Then If UBound($sMobs) >= 1 And $sMobs[0] <> "init" Then ReDim $sMobs[UBound($sMobs)+1] EndIf Dim $tmp[2] $tmp[0] = $aMobDies[1] $tmp[1] = 1 $sMobs[UBound($sMobs)-1] = $tmp EndIf EndIf $aExp = StringRegExp($test, "\[([0-9:]*?)\] You get ([0-9,]*?) experience points. \(([0-9,]*?) ([0-9,]*?) bonus\)", 1) If IsArray($aExp) Then EndIf $aTaskExp = StringRegExp($test, "\[([0-9:]*?)\] You have completed your task and earn ([0-9,]*?) experience!", 1) If IsArray($aTaskExp) Then EndIf $aLootMoneyC = StringRegExp($test, "\[([0-9:]*?)\] You pick up ([0-9,]*?) copper pieces.", 1) If IsArray($aLootMoneyC) Then EndIf $aLootMoneySC = StringRegExp($test, "\[([0-9:]*?)\] You pick up ([0-9,]*?) silver, and ([0-9,]*?) copper pieces.", 1) If IsArray($aLootMoneySC) Then EndIf $aLootMoneyGSC = StringRegExp($test, "\[([0-9:]*?)\] You pick up ([0-9,]*?) gold, ([0-9,]*?) silver, and ([0-9,]*?) copper pieces.", 1) If IsArray($aLootMoneyGSC) Then EndIf $aTaskMoneyC = StringRegExp($test, "\[([0-9:]*?)\] You have completed your task and earn ([0-9,]*?) copper pieces!", 1) If IsArray($aTaskMoneyC) Then EndIf $aTaskMoneySC = StringRegExp($test, "\[([0-9:]*?)\] You have completed your task and earn ([0-9,]*?) silver, and ([0-9,]*?) copper pieces!", 1) If IsArray($aTaskMoneySC) Then EndIf $aTaskMoneyGSC = StringRegExp($test, "\[([0-9:]*?)\] You have completed your task and earn ([0-9,]*?) gold, ([0-9,]*?) silver, and ([0-9,]*?) copper pieces!", 1) If IsArray($aTaskMoneyGSC) Then EndIf $aLoot = StringRegExp($test, "\[([0-9:]*?)\] ([a-zA-Z ]*?) drops (.*?), which you pick up.", 1) If IsArray($aLoot) Then EndIf $aMobAttack = StringRegExp($test, "\[([0-9:]*?)\] ([a-zA-Z ]*?) hits your ([a-zA-Z ]*?) for (.*?) \((.*?)\) damage!", 1) If IsArray($aMobAttack) Then If $aMobAttack[3] > $sMobDmgMax Then $sMobDmgMax = $aMobAttack[3] EndIf $sMobDmgCount += $aMobAttack[3] $sMobDmgDeflected += $aMobAttack[4] EndIf $test = FileReadLine($file) ;_ArrayDisplay($aCast, "") ;_ArrayDisplay($aBlocked, "") ;_ArrayDisplay($aTarget, "") ;_ArrayDisplay($aPerformSkill, "") ;_ArrayDisplay($aAttackMob, "") ;_ArrayDisplay($aMiss, "") ;_ArrayDisplay($aMobMiss, "") ;_ArrayDisplay($aCrit, "") ;_ArrayDisplay($aHeal, "") ;_ArrayDisplay($aMobDies, "") ;_ArrayDisplay($aExp, "") ;_ArrayDisplay($aLootMoneyC, "") ;_ArrayDisplay($aLootMoneySC, "") ;_ArrayDisplay($aLootMoneyGSC, "") ;_ArrayDisplay($aLoot, "") ;_ArrayDisplay($aMobAttack, "") ;_ArrayDisplay($aTaskMoneyC, "") ;_ArrayDisplay($aTaskMoneySC, "") ;_ArrayDisplay($aTaskMoneyGSC, "") ;_ArrayDisplay($aTaskExp, "") WEnd $file = FileOpen("C:\test.log", 2) write("DAMAGE TOTALS") write("-------------") write("Maximum Damage: " & $sDmgMax) write("Total Damage from Crits: " & $sDmgCrit) write("Total Damage: " & $sDmgCount) write("Total Damage mobs resisted: " & $sDmgDeflected) write("-------------") write("Maximum Mob Damage: " & $sMobDmgMax) write("Total Mob Damage: " & $sMobDmgCount) write("Total Mob Damage you resisted: " & $sMobDmgDeflected) write("") write("MOBS") write("-------------") write(" [0]= Name of Mob") write(" [1]= Number of Times Killed") write("-------------") write(_ArrayDisplay2($sMobs, "Mobs Killed", 0)) write("SPELLS") write("-------------") write(" [0]= Name of Spell") write(" [1]= Number of Casts") write("-------------") write(_ArrayDisplay2($sSpellCount, "Spells Casted", 0)) FileClose($file) Func _ArrayDisplay2($arr, $title, $flag) $str = "" If IsArray($arr) Then For $i = 0 To UBound($arr)-1 $str &= "[" & $i & "]= " $str &= _ArrayDisplay2Sub($arr[$i], 1) $str &= @CRLF Next If $flag == 1 Then MsgBox(0, $title, $str) EndIf Else If $flag == 1 Then MsgBox(0, $title, $arr) EndIf EndIf Return $str EndFunc Func _ArrayDisplay2Sub($arr, $count) $str = "" If IsArray($arr) Then For $i = 0 to UBound($arr)-1 $str &= @CRLF For $c = 1 To $count $str &= " " Next $str &= "[" & $i & "]= " $str &= _ArrayDisplay2Sub($arr[$i], $count+1) Next Return $str Else Return $arr EndIf EndFunc Func write($str) FileWriteLine($file, $str & @CRLF) EndFunc Good Luck! [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
huldu Posted March 2, 2006 Author Posted March 2, 2006 (edited) Very very impressive, i like your versions of StringRegExp, gave me some new ideas! The final log output was really great, i was looking into making something that counted how many times each monster had been killed. This looks great! thank you! <Edit> I dont understand how your version can be so fast, 25 seconds vs mine that does pretty much same thing in 44 seconds. Gonna go thru the code and see what makes it so good. </Edit> <Edit> Found out why yours were faster. It stops at *** Chat Log Closed, which happens a third down the log </edit> Edited March 2, 2006 by huldu "I'm paper, rock is fine, nerf scissors!!!"
neogia Posted March 2, 2006 Posted March 2, 2006 Very very impressive, i like your versions of StringRegExp, gave me some new ideas!The final log output was really great, i was looking into making something that counted how many times each monster had been killed. This looks great! thank you!<Edit> I dont understand how your version can be so fast, 25 seconds vs mine that does pretty much same thing in 44 seconds. Gonna go thru the code and see what makes it so good. </Edit><Edit> Found out why yours were faster. It stops at *** Chat Log Closed, which happens a third down the log </edit>Oh, wow, I didn't even realize that. I put that in as a dirty fix because for some reason, the EOF flag didn't raise. Oh well, you can either just do one log at a time or I'll look into why it wouldn't quit on EOF tonight after work. In either case, I have a couple questions:-Do Mobs crit you? I couldn't find one of those.-Do you have an example of platina in a log?-Do you have an example of looting other than "a bag of coins"? [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
huldu Posted March 2, 2006 Author Posted March 2, 2006 Oh, wow, I didn't even realize that. I put that in as a dirty fix because for some reason, the EOF flag didn't raise. Oh well, you can either just do one log at a time or I'll look into why it wouldn't quit on EOF tonight after work. In either case, I have a couple questions:-Do Mobs crit you? I couldn't find one of those.-Do you have an example of platina in a log?-Do you have an example of looting other than "a bag of coins"?Monsters never crit on players. If a player however crits on another player, you wont see the crit it will be his basedmg+the crit. So if he hits you for 50 and crits for 25 it would show up as 75 dmg.Platina never drops from monsters, gold however does. Im gonna see if i can do some more logs.The loot is a big difference, it can be pretty much anything. Anything from a bone to weapons, armor etc. "I'm paper, rock is fine, nerf scissors!!!"
huldu Posted March 2, 2006 Author Posted March 2, 2006 Ive added my modifed version of your code below, so you can check it out. Some very nice improvements. Ive picked alot of the code apart to see what it does etc.GREATLogParser.au3 "I'm paper, rock is fine, nerf scissors!!!"
neogia Posted March 2, 2006 Posted March 2, 2006 (edited) Ive added my modifed version of your code below, so you can check it out. Some very nice improvements.Ive picked alot of the code apart to see what it does etc.I changed it so that instead of telling you how long it takes to read 100 lines, it tells you lines per second. (On my PC, it just alternated between ~470ms and ~1500ms)Tomorrow, I'll work on implementing the other info into arrays. I really like how this is developing.Edit: Uploaded new version.GREATLogParser.au3 Edited March 2, 2006 by neogia [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
huldu Posted March 2, 2006 Author Posted March 2, 2006 Ive made a new chat.log updated with various information. You can look for these lines(in the log): ------ , i wrote information on what happend etc to give some insight.chat.rar "I'm paper, rock is fine, nerf scissors!!!"
neogia Posted March 4, 2006 Posted March 4, 2006 I've modified it some more, it now shows average statistics for each type of mob. I've also optimized the code a bit, so now it gets 209 lines/sec on my PC as opposed to the 67 lines/sec I was getting yesterday. Hot stuff.GREATLogParser.au3 [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now