creating a combat log file

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

creating a combat log file

#1 Post by 123botter »

Welcome everyone! This is my first post in the forum.

Firstly, I am not a programmer. I am just a RoM player, botting for crafting mats only, yet :)
Question... Well, question is nooby - sorry for that. Maybe it was answered already. If the answers exists, please send a link, as I could not find it myself.

Q: How to record a combat log in a text/csv file? A log file should look like this, for example:
Name Type of attack Damage
1. Boar Stab 10
2. Playername - 20 --- means: player has hit using white attack and made 20 damage
3. Boar Slash Dodge
4. Boar - Miss --- means: boar missed while using white attack
5. Playername Holy strike 30
etc..
...
25 Boar is dead!

I am not thinking about logging while botting, actually. I am thinking of adding a few lines (can't be more than that! I hope:))) of lua code in an existing combat log addon - for example Advanced Combat Log addon, which actually spits out all the information into the game's chat window, instead of recording in a file, where I wish it would... It is written in lua, too right?

Do I have to explain why this would be a milestone? :) If I could programm, it would be a first thing to write...The game is missing the combat logging, which is a terrible thing in my opinion.
Is there anyone, who can help?
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#2 Post by rock5 »

That would be suited to a game addon but I believe the game doesn't allow saving to a file, unless you want to save to the 'savevariables.lua' file, which is probably not advised.

I believe there is an addon that allows you to select and copy from the chat window. Maybe that will serve your needs.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#3 Post by 123botter »

Thank you very much for a quick answer, rock5.
Actually saving into savevariables.lua is perfectly enough (as long as it is not too timeconsuming to extract "the juice" from that file again). I would like to record what combat log prints in a chat window in any file.
I presume the task can be acheived in 3 different ways:
1. adding some lines to an existing addon, which already works on chat window variables. My first idea was Advanced Combat Log addon. These extra lines of code would export the variables in a text file.
2. writing a new addon.
3. manual copy/pasting using the addon you mention, rock5.

I have found an abandoned CopyChat, but it still works. Basically it makes a new window, which can be opened using a /cc command or from AddonManager. All messages from the game's chat frame tabs are copied into that new window. They can be viewed, marked and copied from there... but you can copy each line of action separately only...

Solution no. 2 is not possible. Solution no. 3 is too time consuming.
The only solution left is no.1 After seeing how CopyChat works, the extra code can be implemented in either one the addons ACL or CopyChat, because they both share variables. Question is, which addon has simpler environment of variables to export to a file.

So... Anyone willing to help? Guys, if you help me in creating this:), I promise to make a great tanking compedium! At first... later for dpses and healers as well, maybe.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#4 Post by rock5 »

Well, if you have a combat chat addon and it formats the messages the way you like then you should use that.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#5 Post by 123botter »

rock5, could you help me in it? I do not know how to copy those strings and save them in the savevariables.lua:(
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#6 Post by rock5 »

Pretty simple really. All you have to do is define a table to hold the log, save it in the savevariables then add log entries as it writes them to chat. Then when you log off it will save the log as well. (So you will have to log off to view the log.

So first, where it does it's own savevariables, we do our own. There are 3 but I think the one in AdvCombatLog_VerCheck is enough. It is at about line 34 in AdvCombatLogFunction.lua

Code: Select all

function AdvCombatLog_VerCheck()
	local flag = false;
	if (not AdvCombatLog_Config) then
		AdvCombatLog_Config = AdvCombatLog_ConfigDefault;
	end
	if (tonumber(AdvCombatLog_Config["ver"]) < tonumber(ACL_VERSION)) then
		if (tonumber(AdvCombatLog_Config["ver"]) < tonumber(0.45)) then
			AdvCombatLog_Config = AdvCombatLog_ConfigDefault;
		elseif (tonumber(AdvCombatLog_Config["ver"]) < tonumber(0.46)) then
			AdvCombatLog_Config["order"] = AdvCombatLog_ConfigDefault["order"];
		end
		AdvCombatLog_Config["ver"] = ACL_VERSION;
		flag = true;
	end
	SaveVariables("AdvCombatLog_Config");
	if (flag) then
		DEFAULT_CHAT_FRAME:AddMessage(string.format(AdvCombatLog_Lang_UP.."|r", "|cffffffff"..ACL_ADDON_NAME.."|r|cff00ccf"), 255, 255, 255);
	end
	return;
end
Near the end of that function, just before the 'return' add

Code: Select all

AdvCombatLog_Log = {}
SaveVariablesPerCharacter(AdvCombatLog_Log)
Note: I'm using the per character savevariables because the main savevariables can get quite large and cumbersome to search through.

Now I have to find where it writes the chat message and save it. Looks like what it does is on the CHAT_MSG_COMBAT event it intercepts 'arg1' (the message), re-formats it, and saves it back to 'arg1' and leaves it to the system to write it to chat.

The end of AdvCombatLog.lua looks like this.

Code: Select all

	elseif (event == "CHAT_MSG_COMBAT") then
		if (ACL_LOADED) then
			if (AdvCombatLog_Config["options"][1] and arg1 ~= nil) then
				local aclarg = arg1;
				local i;
				local n = 0;
				aclarg = string.gsub(aclarg, "|r", "");
				aclarg = string.gsub(aclarg, "|c........", "");
				for i = 1, table.getn(AdvCombatLogStrings) do
					if (string.find(aclarg, AdvCombatLogStrings[i][1])) then
						n = i;
						break;
					end
				end
				if (n ~= 0) then
					if (AdvCombatLog_Config["options"][4]) then
						aclarg = AdvCombatLog_ShortLog(aclarg, n);
					else
						aclarg = AdvCombatLog_NormalLog(aclarg, n)
					end
					local lbr = AdvCombatLog_Config["options"][5][1];
					local rbr = AdvCombatLog_Config["options"][5][2];
					if (ACL_ENTIME) then
						if (AdvCombatLog_Config["options"][2]) then
							local TS = AdvCombatLog_Config["colors"][7];
							TS = AdvCombatLog_RGBToHex(TS["r"], TS["g"], TS["b"]);
							aclarg = lbr.."|cff"..TS..os.date(AdvCombatLog_Config["options"][3]).."|r"..rbr.." "..aclarg;
						end
					end
					local NT = AdvCombatLog_Config["colors"][1];
					arg1 = aclarg;
					ACL_Temp = {};
				end
			end
		end
	end
end
This is the whole "CHAT_MSG_COMBAT" event handler.

You need to add

Code: Select all

table.insert(AdvCombatLog_Log, aclarg)
I think the best place is just after it strips the link formating and before it adds it's own formatting so you get the cleanest log entry. So just after these 2 line.

Code: Select all

				aclarg = string.gsub(aclarg, "|r", "");
				aclarg = string.gsub(aclarg, "|c........", "");
We could also add an option to switch it on or off if you like so it doesn't log every battle. Let me know if you want that.

Note: this has not been tested. Hope it works.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#7 Post by 123botter »

Fantastic! I will work on it tonight! I will post the results later. I can't express my gratitude to you, Rock5.
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#8 Post by 123botter »

Rock5, I does not work:/ The addon does not start.
By the way - reformatted log messages (short log option of ACL) would be better to store.

pasting what I edited:

AdvCombatLogFunctions.lua

Code: Select all

...
function AdvCombatLog_VerCheck()
	local flag = false;
	if (not AdvCombatLog_Config) then
		AdvCombatLog_Config = AdvCombatLog_ConfigDefault;
	end
	if (tonumber(AdvCombatLog_Config["ver"]) < tonumber(ACL_VERSION)) then
		if (tonumber(AdvCombatLog_Config["ver"]) < tonumber(0.45)) then
			AdvCombatLog_Config = AdvCombatLog_ConfigDefault;
		elseif (tonumber(AdvCombatLog_Config["ver"]) < tonumber(0.46)) then
			AdvCombatLog_Config["order"] = AdvCombatLog_ConfigDefault["order"];
		end
		AdvCombatLog_Config["ver"] = ACL_VERSION;
		flag = true;
	end
	SaveVariables("AdvCombatLog_Config");
	if (flag) then
		DEFAULT_CHAT_FRAME:AddMessage(string.format(AdvCombatLog_Lang_UP.."|r", "|cffffffff"..ACL_ADDON_NAME.."|r|cff00ccf"), 255, 255, 255);
	end

AdvCombatLog_Log = {};
SaveVariablesPerCharacter(AdvCombatLog_Log);

	return;
end
...
AdvCombatLog.lua

Code: Select all

...
				aclarg = string.gsub(aclarg, "|r", "");
				aclarg = string.gsub(aclarg, "|c........", "");

table.insert(AdvCombatLog_Log, aclarg);

				for i = 1, table.getn(AdvCombatLogStrings) do
					if (string.find(aclarg, AdvCombatLogStrings[i][1])) then
						n = i;
						break;
					end
...
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#9 Post by rock5 »

What I described was basically correct but because I'm not so familiar with creating addons, I didn't know that the save variables commands require a string of the variable name, not the variable itself.

Change

Code: Select all

SaveVariablesPerCharacter(AdvCombatLog_Log);
to

Code: Select all

SaveVariablesPerCharacter("AdvCombatLog_Log");
123botter wrote:By the way - reformatted log messages (short log option of ACL) would be better to store.
The problem is, the "short" version includes color formating so it saves like this

Code: Select all

 	[1] = "|cff00ff34Acaron|r > |cff00ccfcCharged Chop|r > |cffff0a00Agile Shadow Mink|r < |cffffdd22260934|r < |cffff9200Life|r",
That's hardly legible.

If you want to use the "short" format then you will have to move those lines down to the end of that section and precede it with those lines that strip the color format.

Move the table insert to the end of that function and copy those 2 lines from line 159-160 so the end of the function looks like this.

Code: Select all

					local NT = AdvCombatLog_Config["colors"][1];
					arg1 = aclarg;
					ACL_Temp = {};
				end

aclarg = string.gsub(aclarg, "|r", "");
aclarg = string.gsub(aclarg, "|c........", "");
table.insert(AdvCombatLog_Log, aclarg);

			end
		end
	end
end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#10 Post by 123botter »

ACL still does not start.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#11 Post by rock5 »

What do you mean by "ACL doesn't start"? I tested the addon and it worked.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#12 Post by 123botter »

After adding your lines to the the lua files, the addon is not working (no miniicon on AddonManager, /acl command does not work either). Doing something wrong? I attach my modified files...
Attachments
AdvCombatLog.lua
(6.17 KiB) Downloaded 106 times
AdvCombatLogFunctions.lua
(12.62 KiB) Downloaded 116 times
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#13 Post by rock5 »

Even though you haven't finished all the changes I said, I can't see why it wouldn't load. If there was a syntax error of some kind you would have received an in game error message (flashing icon near the minimap).

The only difference I don't understand, as shown by KDIFF, is the first line of each file.

Yours

Code: Select all

--[[ ä
Mine

Code: Select all

--[[ ä
Now, that's in a comment so I don't see how that could be a problem but this may just indicate that you are not using a proper code editor such as notepad++ so the file might not be saved properly. I'm no expert on this though.

If you aren't using a proper code editor I suggest you get notepad++ and use that for all future code editing (associate it with lua and xml files).

Here are the files I did. They include the last steps I mentioned in my last post.
Attachments
AdvCombatLogFunctions.lua
(12.61 KiB) Downloaded 121 times
AdvCombatLog.lua
(6.26 KiB) Downloaded 133 times
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#14 Post by 123botter »

Hi Rock5!
Your file AdvCombatLogFunctions.lua had

Code: Select all

SaveVariablesPerCharacter(AdvCombatLog_Log);
instead of

Code: Select all

SaveVariablesPerCharacter("AdvCombatLog_Log");
, so you may have sent me a prevous version. No problem. I added "" (using Notepad++ now) and it is working now! Combat log in a text file:) Thank you very much, Rock5.
Do you know any programs using scripts for text files manipulation? You know, what my goal is...:) to make my task complete I would need the savevariables.lua in a format of csv file - importable by a spreadsheet.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#15 Post by rock5 »

You could just copy it to excel and then do a TextToColumns on it.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#16 Post by 123botter »

Problem is there is not always the same amount of information in each line. So sometimes damage will be in column E sometinmes in F, for example... Also a skill sometimes have 2 words, f.ex. Holy Strike. I just came on an idea to reformat the aclarg, so that it it has the commas in it, and do the reformatting just before it is saved in AdvCombatLog_Log table. I would need to know lua the commands for manipulting strings, which I do not... Well maybe I will figure that out. In the meantime I will play with TextToColumns.
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#17 Post by 123botter »

this is what I get in excel

Code: Select all

xxx     Boar     217		
Boar    xxx     Dodge		
Boar    xxx     Dodge		
Boar    xxx     Dodge		
Boar    Stab    xxx      4     Parry
Boar    xxx     Dodge		
Boar    xxx     Dodge		
xxx     Boar    282		
I am afraid that I will have to manually work on the above datas. however having the above with a single click is huge step forward already.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: creating a combat log file

#18 Post by rock5 »

How do you want the output in excel to look?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
123botter
Posts: 11
Joined: Thu Apr 04, 2013 12:35 pm

Re: creating a combat log file

#19 Post by 123botter »

The present output is workable (i work using conditional counting and summing formulas in openoffice, yet it requires some effort, because alsmot every time formulas must be adjusted to the output).
I think the best output would be something like - 1st column: who (player name or mob name), 2nd: casts what (if it is a white hit, then it should say like 'white hit' instead of skipping the column as it currently does), 3rd col.: amount of damage dealt or 'Miss' or 'Dodge' or 'Parry', 4th: only if Parry occured, then it shoulg give amount of damage after Parry. But to be honest any ideas are welcome.
There is problem with Miss, Dodge, Parry. When there is Miss, Dodge, Parry it never shows which skill/spell was cast. So you could assume, that only 'white hits' can be missed, dodged, parried, which does not seem to be correct. Instead ot this I made assumption that white hits and skills or spells are evenly avoided, so for example - Dodge rating = amnt of all attacks (skill hits + white hits) / amount of dogded attacks.
(the info to whom the damage was dealt is not needed).
Buffs as well HoTs and DoTs should be excluded from the log, or there should be a way to exclude them on demand.

Also is it possible to export some character stats (Accu, PDEF, MDEF, Dodge etc.) into saveviariables.lua, too? After each fight we would have automatically all the data for analysis. Let's say stats from the beginning of the fight, because during the fight the buffs my change them.
After preliminary tests, there is a huge variance - if I call it correctly - in the measurements. As you know the authors of the game were so "kind" that they did not give any (except Parry) indication to the rating of each skill. They gave VALUES instead, which tell nothing - f.ex. Physical Defense instead of Defense- or Armor Rating (% of damage mitigated), they gave Accuracy instead of hit % rating, gave Dodge instead of dodge % rating etc.
I will continue tests a few days more, but I may not be able to find the dependencies alone. It seems like the task is much more work then I thought. Does anyone want to join a project aiming at finding out the rating formulas? With your help Rock5, the tool is almost ready.
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: creating a combat log file

#20 Post by lisa »

First thing I notice about this addon is it doesn't show criticals.

Had a browse in CE and there is no "localise" variable for crits, they are all hard coded in the messages themselves.

Code: Select all

SYS_COMBAT_MAGIC_CRITIAL_SELF
[$MN] critically hits you and takes [$VA] [$AT] points
So in order to have a record of crits you need to add it to the AdvCombatLogPatterns.lua

Code: Select all

if (not AdvCombatLogKeywords) then
	AdvCombatLogKeywords = {};
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_ABORB"));
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_DODGE"));
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_END"));
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_IMMUNE"));
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_MISS"));
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_PARRY"));
	table.insert(AdvCombatLogKeywords, TEXT("FIGHT_START"));
	table.insert(AdvCombatLogKeywords, "critically");
end
Note this will only work for english as other languages would more than likely have a different word than "critically"

This little change will make it look like this.

Code: Select all

	[1] = "[01:19:22 pm] Magic Frog > Charname > Fireball < 32608 < critically < Life",
	[2] = "[01:19:29 pm] Zapa River Ostrich > Charname > Lightning < 27104 < critically < Life",
	[3] = "[01:19:34 pm] Magic Frog > Charname > Purgatory Fire < 18521 < critically < Life",
	[4] = "[01:19:34 pm] Zapa River Ostrich > Charname > Purgatory Fire < 18093 < critically < Life",
	[5] = "[01:19:38 pm] Magic Frog > Charname > Purgatory Fire < 18405 < critically < Life",
	[6] = "[01:19:45 pm] Charname > Zapa River Chupura > Shearing Bite < 12 < Life",
	[7] = "[01:19:46 pm] Charname > Zapa River Chupura > Bleed < 50 < Life",
	[8] = "[01:19:48 pm] Charname > Zapa River Chupura > Bleed < 50 < Life",
Something else that bothers me is that self heals/buffs/items don't have any values for target or Attacker, I think they should default to charname. I might have a look at it.
123botter wrote:I think the best output would be something like - 1st column: who (player name or mob name), 2nd: casts what (if it is a white hit, then it should say like 'white hit' instead of skipping the column as it currently does), 3rd col.: amount of damage dealt or 'Miss' or 'Dodge' or 'Parry', 4th: only if Parry occured, then it shoulg give amount of damage after Parry. But to be honest any ideas are welcome.
You can alter the order in which things are "printed" very easily.
/acl then click on "shortlog order"

you probably just want


Value
Skill/Effect
Keywords
Attacker

You could then just use the first 3 values, if there is no 4th value then it would have been a heal/buff/item.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Post Reply