This tutorial is meant for those that like using 010 Editor and have an idea of how to create and/or modify scripts and templates.
I love the power of 010 Editor for doing mass edits and things, but for some files I like the power of excel (filtering, copying, etc). This tutorial will show you how I edit ItemLooting.dat in Excel and use 010 editor to export and import.
I am not giving every single step in this tutorial. I use the scripts and templates released by Intrepid Web. You may need to change some variable names if they are different for you. This is just a guide as to how to write the scripts needed to do this.
Script 1, the export:
Utilizing the code above, you will have a csv file containing the contents of ItemLooting. In some cases you can simply double click to open the file in excel, BUT you may get some formatting that you don't want. For this particular file, I opened excel and imported the data from text. To import, you need to choose "Delimited", then Comma instead of Tab, then for item looting I picked the column with the mob codes and selected "Text" instead of "General" for the formatting. The data is then imported and you can change what you wish. You can filter out groups of mobs, add new rows, filter based on items, etc. you do still need to adhere to the rule of keeping all mob rows together (all loot rows for a mob must be next to each other).
Once complete simply save the file as a new csv or overwrite the existing one (excel will warn you about formatting, but you don't want the formatting).
When you are done editing, it is time to import it with this script. Import really isn't the best term here as you are actually creating a new file:
Test, rinse and repeat when needed.
You can also do some things in the script if you like. I ignored all rows that had "0" for the lootRate on the export and got rid of unused lines.
If there are enough people that use 010 Editor and would like to get the SVN active again for templates and scripts, let me know.
I love the power of 010 Editor for doing mass edits and things, but for some files I like the power of excel (filtering, copying, etc). This tutorial will show you how I edit ItemLooting.dat in Excel and use 010 editor to export and import.
I am not giving every single step in this tutorial. I use the scripts and templates released by Intrepid Web. You may need to change some variable names if they are different for you. This is just a guide as to how to write the scripts needed to do this.
Script 1, the export:
Code:
//--------------------------------------
//--- 010 Editor v5.0 Script File
//
// File: item_looting_export.1sc
// Author: GMoney
// Revision:
// Purpose:
//--------------------------------------
string savePath = "C:\\PathTo\\export.csv";
int i, y;
int curFile = GetFileNum();
int newFile = FileNew();
string currentLine = "";
string temp = "";
DeleteFile( savePath );
FileSelect( curFile );
for(i = 0; i < header.blocks; i++)
{
currentLine = "";
if(item[i].lootRate > 0)
{
//I am using templates released by Intrepid Web
//We are simply writing the comma delimited values to a csv file
SPrintf(temp, "%s", item[i].base.code);
currentLine += temp;
currentLine += ",";
SPrintf(temp, "%d", item[i].lootRate);
currentLine += temp;
currentLine += ",";
SPrintf(temp, "%d", item[i].lootTime);
currentLine += temp;
currentLine += ",";
SPrintf(temp, "%d", item[i].operationCount);
currentLine += temp;
currentLine += ",";
SPrintf(temp, "%d", item[i].totalLoot);
currentLine += temp;
currentLine += ",";
for(y = 0; y < 200; y++)
{
SPrintf(temp, "%s", item[i].item[y].code);
currentLine += temp;
if(y != 199)
currentLine += ",";
}
currentLine += "\n";
FPrintf(newFile, "%s", currentLine);
}
}
FileSelect( newFile );
FileSave( savePath );
FileClose();
Utilizing the code above, you will have a csv file containing the contents of ItemLooting. In some cases you can simply double click to open the file in excel, BUT you may get some formatting that you don't want. For this particular file, I opened excel and imported the data from text. To import, you need to choose "Delimited", then Comma instead of Tab, then for item looting I picked the column with the mob codes and selected "Text" instead of "General" for the formatting. The data is then imported and you can change what you wish. You can filter out groups of mobs, add new rows, filter based on items, etc. you do still need to adhere to the rule of keeping all mob rows together (all loot rows for a mob must be next to each other).
Once complete simply save the file as a new csv or overwrite the existing one (excel will warn you about formatting, but you don't want the formatting).
When you are done editing, it is time to import it with this script. Import really isn't the best term here as you are actually creating a new file:
Code:
//--------------------------------------
//--- 010 Editor v5.0 Script File
//
// File: item_looting_import.1sc
// Author: GMoney
// Revision:
// Purpose:
//--------------------------------------
//#include "general_functions.1sc";
//If you are using Intrepid Web scripts, simply add this to general_functions.1sc
int string_to_int(string number)
{
int len, i, return_num = 0;
len = Strlen(number);
for(i = 0; i < len; i++)
{
return_num = return_num * 10 + (number[i] - '0');
}
return return_num;
}
//path to the csv to import from
string importPath = "C:\\PathTo\\import.csv";
string destinationPath = "C:\\PathTo\\ItemLooting.dat";
int i = 0, y, pos, eofPos = 0, currentItem = 0;
int newFile = FileNew();
int csvFile = FileOpen(importPath);
int fileSize, delIndex;
char currentLine[];
string temp = "";
int numItems = 0;
//INSERT HEADER INFO
FileSelect( newFile );
InsertBytes(0, 4);
WriteInt(eofPos, 1); //placeholder for number of blocks
eofPos += 4;
InsertBytes(eofPos, 4);
WriteInt(eofPos, 206); //number of columns
eofPos += 4;
InsertBytes(eofPos, 4);
WriteInt(eofPos, 1684); //block size
eofPos += 4;
//PARSE CSV
FileSelect( csvFile );
fileSize = FileSize();
pos = 0;
while (pos < fileSize)
{
FileSelect( csvFile );
currentLine = ReadLine(pos, -1);
pos += Strlen(currentLine);
currentLine += ",";
FileSelect( newFile );
InsertBytes(eofPos, 4);
WriteUInt(eofPos, numItems); //index
eofPos += 4;
currentItem = 0;
while(Strstr(currentLine, ",") > 0)
{
// Get the first commans position
delIndex = Strstr(currentLine, ",");
if(currentItem == 0)
{
//Mob code
InsertBytes(eofPos, 64);
WriteString(eofPos, SubStr(currentLine, 0, delIndex));
eofPos += 64;
}
else if (currentItem < 5)
{
//lootrate, loottime, operationcount, totalloot
InsertBytes(eofPos, 4);
WriteInt(eofPos, string_to_int(SubStr(currentLine, 0, delIndex)));
eofPos += 4;
}
else
{
//item
InsertBytes(eofPos, 8);
WriteString(eofPos, SubStr(currentLine, 0, delIndex));
eofPos += 8;
}
currentItem++;
currentLine = SubStr(currentLine, delIndex+1, -1);
}
numItems++;
}
//rewrite the block count
DeleteBytes(0, 4);
InsertBytes(0, 4);
WriteInt(0, numItems);
FileSave( destinationPath );
FileClose();
Test, rinse and repeat when needed.
You can also do some things in the script if you like. I ignored all rows that had "0" for the lootRate on the export and got rid of unused lines.
If there are enough people that use 010 Editor and would like to get the SVN active again for templates and scripts, let me know.