summaryrefslogtreecommitdiff
path: root/hercules/code/server/tmw
diff options
context:
space:
mode:
Diffstat (limited to 'hercules/code/server/tmw')
-rw-r--r--hercules/code/server/tmw/__init__.py0
-rw-r--r--hercules/code/server/tmw/athena.py207
-rw-r--r--hercules/code/server/tmw/consts.py129
-rw-r--r--hercules/code/server/tmw/itemdb.py291
-rw-r--r--hercules/code/server/tmw/main.py49
-rw-r--r--hercules/code/server/tmw/mobdb.py173
-rw-r--r--hercules/code/server/tmw/mobskilldb.py55
-rw-r--r--hercules/code/server/tmw/npcs.py878
8 files changed, 1782 insertions, 0 deletions
diff --git a/hercules/code/server/tmw/__init__.py b/hercules/code/server/tmw/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hercules/code/server/tmw/__init__.py
diff --git a/hercules/code/server/tmw/athena.py b/hercules/code/server/tmw/athena.py
new file mode 100644
index 0000000..6548b2e
--- /dev/null
+++ b/hercules/code/server/tmw/athena.py
@@ -0,0 +1,207 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2015 Evol Online
+# Author: Andrei Karas (4144)
+
+import re
+
+from code.stringutils import stripNewLine
+from code.server.dbitem import Item
+from code.server.dbskill import Skill
+from code.server.dbuser import User
+
+comaSplit = re.compile(",")
+spaceSplit = re.compile(" ")
+
+def parseInventory(line, data):
+ items = []
+
+ if data == "":
+ return items
+
+ rows = spaceSplit.split(data)
+ if len(rows) < 1:
+ return items
+
+ for data2 in rows:
+ if data2 == "":
+ continue
+
+ rows2 = comaSplit.split(data2)
+
+ if len(rows2) != 12:
+ print "wrong inventory in account.txt line: " + stripNewLine(line)
+ continue
+
+ item = Item()
+
+ item.uknownId = rows2[0]
+ item.itemId = rows2[1]
+ item.amount = rows2[2]
+ item.equip = rows2[3]
+ item.color = rows2[4]
+ item.refine = rows2[5]
+ item.attribute = rows2[6]
+ item.card0 = rows2[7]
+ item.card1 = rows2[8]
+ item.card2 = rows2[9]
+ item.card3 = rows2[10]
+ item.broken = rows2[11]
+
+ items.append(item)
+
+ return items
+
+def parseSkills(line, data):
+ skills = []
+
+ if data == "":
+ return skills
+
+ rows = spaceSplit.split(data)
+ if len(rows) < 1:
+ return skills
+
+ for data2 in rows:
+ if data2 == "":
+ continue
+
+ rows2 = comaSplit.split(data2)
+
+ if len(rows2) != 2:
+ print "wrong skills in account.txt line: " + stripNewLine(line)
+ continue
+
+ skill = Skill()
+ skill.skillId = rows2[0]
+ skill.level = int(rows2[1]) & 0xffff
+ skill.flags = (int(rows2[1]) * 0xffff) & 0xffff
+
+ skills.append(skill)
+
+ return skills
+
+def parseVars(line, data):
+ variables = {}
+
+ if data == "":
+ return variables
+
+ rows = spaceSplit.split(data)
+ if len(rows) < 1:
+ return variables
+
+ for data2 in rows:
+ if data2 == "":
+ continue
+
+ rows2 = comaSplit.split(data2)
+
+ if len(rows2) != 2:
+ print "wrong variables in account.txt line: " + stripNewLine(line)
+ continue
+
+ variables[rows2[0]] = rows2[1]
+
+ return variables
+
+def readAthena():
+ srcFile = "olddb/athena.txt"
+ fieldsSplit = re.compile("\t")
+
+ users = {}
+ with open(srcFile, "r") as r:
+ for line in r:
+ if line[:2] == "//":
+ continue
+ rows = fieldsSplit.split(line)
+ if len(rows) == 2:
+ continue
+ if len(rows) != 20:
+ print "wrong account.txt line: " + stripNewLine(line)
+ continue
+
+ user = User()
+
+ user.char_id = rows[0]
+ tmp = comaSplit.split(rows[1])
+ user.account_id = tmp[0]
+ user.char_num = tmp[1]
+ user.char_name = rows[2]
+
+ tmp = comaSplit.split(rows[3])
+ user.char_class = tmp[0]
+ user.base_level = tmp[1]
+ user.job_level = tmp[2]
+
+ tmp = comaSplit.split(rows[4])
+ user.base_exp = tmp[0]
+ user.job_exp = tmp[1]
+ user.zeny = tmp[2]
+
+ tmp = comaSplit.split(rows[5])
+ user.hp = tmp[0]
+ user.max_hp = tmp[1]
+ user.sp = tmp[2]
+ user.max_sp = tmp[3]
+
+ tmp = comaSplit.split(rows[6])
+ user.stat_str = tmp[0]
+ user.stat_agi = tmp[1]
+ user.stat_vit = tmp[2]
+ user.stat_int = tmp[3]
+ user.stat_dex = tmp[4]
+ user.stat_luk = tmp[5]
+
+ tmp = comaSplit.split(rows[7])
+ user.status_point = tmp[0]
+ user.skill_point = tmp[1]
+
+ tmp = comaSplit.split(rows[8])
+ user.option = tmp[0]
+ user.karma = tmp[1]
+ user.manner = tmp[2]
+
+ tmp = comaSplit.split(rows[9])
+ user.party_id = tmp[0]
+ user.guild_id = tmp[1]
+ user.pet_id = tmp[2]
+
+ tmp = comaSplit.split(rows[10])
+ user.hair = tmp[0]
+ user.hair_color = tmp[1]
+ user.clothes_color = tmp[2]
+
+ tmp = comaSplit.split(rows[11])
+ user.weapon = tmp[0]
+ user.shield = tmp[1]
+ user.head_top = tmp[2]
+ user.head_mid = tmp[3]
+ user.head_bottom = tmp[4]
+
+ tmp = comaSplit.split(rows[12])
+ user.last_map = tmp[0]
+ user.last_x = tmp[1]
+ user.last_y = tmp[2]
+
+ tmp = comaSplit.split(rows[13])
+ user.save_map = tmp[0]
+ user.save_x = tmp[1]
+ user.save_y = tmp[2]
+
+ user.partner_id = "0"
+ user.language_id = "0"
+
+ # skip 14
+
+ user.inventory = parseInventory(line, rows[15])
+
+ # skip 16
+
+ user.skills = parseSkills(line, rows[17])
+
+ user.variables = parseVars(line, rows[18])
+
+ users[user.char_id] = user
+
+ return users
diff --git a/hercules/code/server/tmw/consts.py b/hercules/code/server/tmw/consts.py
new file mode 100644
index 0000000..5b8403e
--- /dev/null
+++ b/hercules/code/server/tmw/consts.py
@@ -0,0 +1,129 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import os
+import re
+
+from code.fileutils import readFile
+from code.stringutils import stripNewLine
+
+fieldsSplit = re.compile(":")
+
+def getConstsFile(srcDir):
+ files = os.listdir(srcDir)
+ for srcFile in files:
+ if srcFile.find("const") == 0 and srcFile[-4:] == ".txt":
+ yield srcDir + srcFile
+
+def readOneConst(r, line):
+ key = ""
+ val = ""
+ depr = 0
+ if line.find(": {") > 0:
+ rows = fieldsSplit.split(line)
+ key = rows[0].strip()
+ line = r.next().strip()
+ rows = fieldsSplit.split(line)
+ if len(rows) != 2:
+ print "error"
+ return ("", "", 0)
+ if rows[0] == "Value":
+ val = rows[1]
+ line = r.next().strip()
+ rows = fieldsSplit.split(line)
+ if len(rows) != 2:
+ print "error"
+ return ("", "", 0)
+ rows[1] = rows[1].strip()
+ if rows[0] == "Deprecated" and rows[1].find("true") == 0:
+ depr = 1
+ else:
+ rows = fieldsSplit.split(line)
+ if len(rows) != 2:
+ return ("", "", 0)
+ key = rows[0];
+ val = rows[1]
+ return (key, val, depr)
+
+def writeConst(w, const):
+ if const[2] == 1:
+ w.write("\t{0}: {{\n\t\tValue:{1}\n\t\tDeprecated: true\n\t}}\n".format(const[0], const[1]))
+ else:
+ w.write("\t{0}:{1}\n".format(const[0], const[1]))
+
+def convertConsts(quests, npcIds):
+ dstFile = "newserverdata/db/constants.conf"
+ fields = dict()
+ vals = [("MF_NOTELEPORT", "mf_noteleport"),
+ ("MF_NORETURN", "mf_noreturn"),
+ ("MF_MONSTER_NOTELEPORT", "mf_monster_noteleport"),
+ ("MF_NOSAVE", "mf_nosave"),
+ ("MF_NOPENALTY", "mf_nopenalty"),
+ ("MF_PVP", "mf_pvp"),
+ ("MF_PVP_NOPARTY", "mf_pvp_noparty"),
+ ("MF_PVP_NOCALCRANK", "mf_pvp_nocalcrank"),
+ ("MF_NOWARP", "mf_nowarp"),
+ ("MF_NOWARPTO", "mf_nowarpto"),
+ ("MF_SNOW", "mf_snow"),
+ ("MF_FOG", "mf_fog"),
+ ("MF_SAKURA", "mf_sakura"),
+ ("MF_LEAVES", "mf_leaves"),
+ ("MF_TOWN", "mf_town"),
+ ("sc_poison", "SC_POISON"),
+ ("sc_slowpoison", "SC_SLOWPOISON"),
+ ("sc_adrenaline", "SC_ADRENALINE"),
+ ]
+ with open(dstFile, "w") as w:
+ tpl = readFile("templates/constants.tpl")
+ w.write(tpl);
+ srcFile = "serverdata/db/constants.conf"
+ with open(srcFile, "r") as r:
+ for line in r:
+ if line.find("**************************************************************************/") >= 0:
+ break
+
+ for line in r:
+ line = line.strip()
+ if len(line) < 2 or line[0:2] == "//" or line[0:2] == "/*":
+ continue
+ const = readOneConst(r, line)
+ if const[0] == "comment__":
+ continue
+ fields[const[0]] = const[1].strip()
+ writeConst(w, const)
+
+ srcDir = "oldserverdata/world/map/db/"
+ w.write("// tmw constants\n")
+
+ fieldsSplit = re.compile("\t+")
+
+ for srcFile in getConstsFile(srcDir):
+ with open(srcFile, "r") as r:
+ for line in r:
+ if len(line) < 2 or line[0:2] == "//":
+ continue
+ line = line.replace(" ", "\t")
+ rows = fieldsSplit.split(line)
+ if len(rows) != 2:
+ continue
+
+ for val in vals:
+ if rows[0] == val[0]:
+ rows[0] = val[1]
+ if rows[0] in quests:
+ rows[1] = str(quests[rows[0]]) + "\n"
+ if rows[0] in fields:
+ if fields[rows[0]] != rows[1][:-1]:
+ print "warning: different const values for {0} ({1}, {2})".format(rows[0], rows[1][:-1], fields[rows[0]])
+ else:
+ writeConst(w, (rows[0], stripNewLine(rows[1]), 0))
+ w.write("// tmw npcs\n")
+ for npc in npcIds:
+ if npc == -1:
+ key = "MINUS1"
+ else:
+ key = str(npc)
+ writeConst(w, ("NPC" + key, npc, 0))
+ w.write("}")
diff --git a/hercules/code/server/tmw/itemdb.py b/hercules/code/server/tmw/itemdb.py
new file mode 100644
index 0000000..dde9aaa
--- /dev/null
+++ b/hercules/code/server/tmw/itemdb.py
@@ -0,0 +1,291 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import os
+import re
+
+from code.configutils import writeStartScript, writeEndScript, writeIntField, writeStrField
+from code.fileutils import readFile
+
+def getItemDbFile(srcDir):
+ files = os.listdir(srcDir)
+ for srcFile in files:
+ if srcFile.find("item_db") >= 0:
+ yield srcFile
+
+def replaceStr(line):
+ vals = [
+ ("setskill ", "addtoskill "),
+ ("zeny", "Zeny"),
+ ("sc_poison", "SC_POISON"),
+ ("sc_slowpoison", "SC_SLOWPOISON"),
+ ("sex", "Sex"),
+ ("SEX", "Sex"),
+
+ (".gat", ""),
+ ("Bugleg", "BugLeg"),
+ ("set BugLeg, 0;", "//set BugLeg, 0;"),
+ ("set CaveSnakeLamp, 0;", "//set CaveSnakeLamp, 0;"),
+ ("set Class, @BaseClass;", "//set Class, @BaseClass;"),
+ ("goto_Exit;", "goto L_Exit;"),
+ ("if @spants_state < 7 goto", "if(@spants_state < 7) goto"),
+ ("isdead()", "ispcdead()"),
+ ("changeSex", "changecharsex()"),
+ ("getpartnerid2()", "getpartnerid()"),
+
+ ("getmap()", "getmapname()"),
+ ("L_end", "L_End"),
+ ("gmcommand", "atcommand"),
+ ("MF_NOSAVE", "mf_nosave"),
+ ("S_update_var", "S_Update_Var"),
+ ("L_teach", "L_Teach"),
+ ("L_focus", "L_Focus"),
+ ("L_unfocus", "L_Unfocus"),
+ ("L_main", "L_Main"),
+ ("L_next", "L_Next"),
+ ("L_close", "L_Close"),
+ ("@NpcName$", "@npcname$"),
+ ("@cost", "@Cost"),
+ ("@TEMP", "@temp"),
+ ("L_Menuitems", "L_MenuItems"),
+ ("L_no_item", "L_No_Item"),
+ ("L_no_water", "L_No_Water"),
+ ("L_NOT_ENOUGH", "L_No_Water"),
+ ("L_bye", "L_Bye"),
+ ("L_NOHELP", "L_NoHelp"),
+ ("L_Eyepatch", "L_EyePatch"),
+ ("@PC_STAMINA", "@pc_stamina"),
+ ("L_magic", "L_Magic"),
+ ("L_cont", "L_Cont"),
+ ("L_accept", "L_Accept"),
+ ("L_no_event", "L_No_Event"),
+ ("L_event_done", "L_Event_Done"),
+ ("L_nobeer", "L_NoBeer"),
+ ("L_iron", "L_Iron"),
+ ("L_sulphur", "L_Sulphur"),
+ ("L_red", "L_Red"),
+ ("L_yellow", "L_Yellow"),
+ ("L_green", "L_Green"),
+ ("L_orange", "L_Orange"),
+ ("L_pink", "L_Pink"),
+ ("L_purple", "L_Purple"),
+ ("L_question", "L_Question"),
+ ("L_quest", "L_Quest"),
+ ("L_dead", "L_Dead"),
+ ("L_menu", "L_Menu"),
+ ("L_give", "L_Give"),
+ ("@Items$", "@items$"),
+ ("@menuItems$", "@menuitems$"),
+ ("L_Teach_initial", "L_Teach_Initial"),
+ ("L_finish", "L_Finish"),
+ ("L_No_ash", "L_No_Ash"),
+ ("L_No_water", "L_No_Water"),
+ ("L_cave", "L_Cave"),
+ ("L_farewell", "L_Farewell"),
+ ("@Q_forestbow_", "@Q_Forestbow_"),
+ ("L_game", "L_Game"),
+ ("L_good", "L_Good"),
+ ("L_abort", "L_Abort"),
+ ("@menuID", "@menuid"),
+ ("L_NO_ITEM", "L_No_Item"),
+ ("L_HELP", "L_Help"),
+ ("L_Noitem", "L_NoItem"),
+ ("L_No_fur", "L_No_Fur"),
+ ("@EXP", "@Exp"),
+ ("L_water", "L_Water"),
+ ("L_get", "L_Get"),
+ ("L_happy", "L_Happy"),
+ ("L_cheat", "L_Cheat"),
+ ("@Reward_EXP", "@Reward_Exp"),
+ ("@REWARD_EXP", "@Reward_Exp"),
+ ("L_no_money", "L_No_Money"),
+ ("@MinLevel", "@minLevel"),
+ ("L_return", "L_Return"),
+ ("L_intro", "L_Intro"),
+ ("L_full", "L_Full"),
+ ("@minlevel", "@minLevel"),
+ ("@MinLevel", "@minLevel"),
+ ("L_Cleanup", "L_CleanUp"),
+ ("L_Alreadystarted", "L_AlreadyStarted"),
+ ("@amount", "@Amount"),
+ ("L_again", "L_Again"),
+ ("L_no_potion", "L_No_Potion"),
+ ("L_wizard_hat", "L_Wizard_Hat"),
+ ("L_notenough", "L_NotEnough"),
+ ("L_offer", "L_Offer"),
+ ("L_giveup", "L_GiveUp"),
+ ("L_not_ready", "L_Not_Ready"),
+ ("@MobID", "@mobId"),
+ ("@mobID", "@mobId"),
+ ("L_naked", "L_Naked"),
+ ("L_shortcut", "L_Shortcut"),
+ ("L_shirt", "L_Shirt"),
+ ("L_goodjob", "L_GoodJob"),
+ ("L_kill", "L_Kill"),
+ ("L_nothing", "L_Nothing"),
+ ("L_lowlevel", "L_LowLevel"),
+ ("@mask", "@Mask"),
+ ("Foice", "FoiceItem"),
+ ("LanternaJack", "LanternaJackItem"),
+ # fix at same time usage with same name function and variable
+ ("\"DailyQuestPoints\"", "\"DailyQuestPointsFunc\""),
+ ("sc_adrenaline", "SC_ADRENALINE"),
+ ];
+
+ for val in vals:
+ line = line.replace(val[0], val[1]);
+ return line
+
+def getItType(it):
+ try:
+ i=int(it)
+ except:
+ i=None
+ if i == 0:
+ return '"IT_HEALING"'
+ elif i == 2:
+ return '"IT_USABLE"'
+ elif i == 3:
+ return '"IT_ETC"'
+ elif i == 4:
+ return '"IT_WEAPON"'
+ elif i == 5:
+ return '"IT_ARMOR"'
+ elif i == 6:
+ return '"IT_CARD"'
+ elif i == 7:
+ return '"IT_HEALING"'
+ elif i == 2:
+ return '"IT_HEALING"'
+ elif i == 2:
+ return '"IT_HEALING"'
+ elif i == 2:
+ return '"IT_HEALING"'
+ else:
+ print("Unrecognized item type: %s" % it)
+ return '"IT_ETC"'
+
+def convertItemDb(isNew):
+ srcDir = "oldserverdata/world/map/db/"
+ dstFile = "newserverdata/db/re/item_db.conf"
+ if os.path.isfile(dstFile):
+ os.remove(dstFile)
+ constsFile = "newserverdata/db/const.txt"
+ if os.path.isfile(constsFile):
+ os.remove(constsFile)
+ fieldsSplit = re.compile(",")
+ scriptsSplit = re.compile("},")
+ scriptsTextClean = re.compile('([{}])')
+ scriptsTextComma = re.compile('^,')
+ scriptsTextColon = re.compile('; ')
+ items = dict()
+
+ tpl = readFile("templates/item_db.tpl")
+ with open(dstFile, "w") as w:
+ w.write(tpl)
+ with open(constsFile, "a") as c:
+ c.write("// items\n");
+ for srcFile in getItemDbFile(srcDir):
+ with open(srcDir + srcFile, "r") as r:
+ for line in r:
+ if len(line) < 2 or line[0] == "#" or line[0:2] == "//":
+ continue
+ line = replaceStr(line)
+ rows = fieldsSplit.split(line)
+ if len(rows) < 5 or rows[0] == "0":
+ continue
+
+ sz = len(rows)
+ if sz > 19:
+ sz = 19
+ for f in xrange(0, sz):
+ rows[f] = rows[f].strip()
+
+ items[rows[1]] = {'id':rows[0],'buy':rows[4],'name':rows[1]}
+ items[rows[0]] = {'id':rows[0],'buy':rows[4],'name':rows[1]}
+ items[int(rows[0])] = {'id':rows[0],'buy':rows[4],'name':rows[1]}
+ # set all values then write
+ w.write("{\n")
+ c.write("{0}\t{1}\n".format(rows[1], rows[0]))
+ writeIntField(w, "Id", rows[0])
+ writeStrField(w, "AegisName", rows[1])
+ if isNew == True:
+ offset = -1
+ else:
+ offset = 0
+ writeStrField(w, "Name", rows[offset + 2])
+ if rows[offset + 3] == "0":
+ itemType = "2"
+ else:
+ itemType = rows[offset + 3]
+ writeIntField(w, "Type", itemType)
+
+ writeIntField(w, "Buy", rows[offset + 4])
+ if int(rows[offset + 4])*.75 <= int(rows[offset + 5])*1.24:
+ writeIntField(w, "Sell", str(int(int(rows[offset + 4])*.50)))
+ else:
+ writeIntField(w, "Sell", rows[offset + 5])
+ writeIntField(w, "Weight", rows[offset + 6])
+ writeIntField(w, "Atk", rows[offset + 7])
+ writeIntField(w, "Matk", "0")
+ writeIntField(w, "Def", rows[offset + 8])
+ writeIntField(w, "Range", rows[offset + 9])
+ writeIntField(w, "Slots", "0")
+ writeIntField(w, "Gender", rows[offset + 12])
+ writeIntField(w, "Loc", rows[offset + 13])
+ writeIntField(w, "WeaponLv", rows[offset + 14])
+ writeIntField(w, "EquipLv", rows[offset + 15])
+ writeIntField(w, "Refine", "false")
+ if isNew == True:
+ offset = 2
+ else:
+ offset = 0
+ if rows[offset + 13] == "2":
+ writeIntField(w, "ViewSprite", "1")
+ elif rows[offset + 13] == "34":
+ writeIntField(w, "ViewSprite", "11")
+ elif rows[offset + 13] == "32768":
+ writeIntField(w, "ViewSprite", "1")
+ elif itemType == "4": # weapon
+ writeIntField(w, "ViewSprite", "1")
+ else:
+ writeIntField(w, "View", rows[0])
+ writeIntField(w, "BindOnEquip", "false")
+ writeIntField(w, "BuyingStore", "false")
+ writeIntField(w, "Delay", "0")
+ writeIntField(w, "Sprite", "0")
+
+ scripts = ""
+ if isNew == True:
+ offset = -1
+ else:
+ offset = 0
+ for f in xrange(offset + 17, len(rows)):
+ scripts = scripts + ", " + rows[f]
+ rows = scriptsSplit.split(scripts)
+ # Needs .split(';') and \n each
+ if len(rows) > 1:
+ UseScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[0]))).strip().split(';')
+ EquipScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[1]))).strip().split(';')
+ else:
+ UseScript = ""
+ EquipScript = ""
+ # move to for stmt
+ if len(UseScript) > 1:
+ writeStartScript(w, "Script")
+ for uline in UseScript:
+ if len(uline) > 0:
+ w.write(" {0};\n".format(uline))
+ writeEndScript(w)
+ if len(EquipScript) > 1:
+ writeStartScript(w, "OnEquipScript")
+ for eline in EquipScript:
+ if len(eline) > 0:
+ w.write(" {0};\n".format(eline))
+ writeEndScript(w)
+
+ w.write("},\n")
+ w.write(")\n")
+ return items
diff --git a/hercules/code/server/tmw/main.py b/hercules/code/server/tmw/main.py
new file mode 100644
index 0000000..bfbf5ef
--- /dev/null
+++ b/hercules/code/server/tmw/main.py
@@ -0,0 +1,49 @@
+#! /usr/bin/env python
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+from sets import Set
+
+from code.server.account import convertAccount
+from code.server.accreg import convertAccReg
+from code.server.party import convertParty
+from code.server.storage import convertStorage
+from code.server.db.char import saveCharTableCustom
+from code.server.db.charregnumdb import saveCharRegNumDbTable
+from code.server.db.inventory import saveInventoryTable
+from code.server.db.skill import saveSkillTable
+from code.server.tmw.athena import readAthena
+from code.server.tmw.consts import convertConsts
+from code.server.tmw.itemdb import convertItemDb
+from code.server.tmw.mobdb import convertMobDb
+from code.server.tmw.mobskilldb import convertMobSkillDb
+from code.server.tmw.npcs import createMainScript, convertNpcs
+from code.server.utils import cleanServerData
+
+def serverTmwMain(isNew):
+ try:
+ cleanServerData()
+ except:
+ print "Updating server"
+ createMainScript()
+ items = convertItemDb(isNew)
+ npcIds = Set()
+ convertNpcs(items, npcIds)
+ convertMobDb(items)
+ quests = dict()
+ convertConsts(quests, npcIds)
+ convertMobSkillDb()
+
+def dbTmwMain():
+ convertAccount()
+ users = readAthena()
+# saveCharTable(users)
+ saveCharTableCustom(users)
+ saveCharRegNumDbTable(users)
+ saveSkillTable(users)
+ saveInventoryTable(users)
+ convertStorage()
+ convertAccReg()
+ convertParty(users)
diff --git a/hercules/code/server/tmw/mobdb.py b/hercules/code/server/tmw/mobdb.py
new file mode 100644
index 0000000..10edfd1
--- /dev/null
+++ b/hercules/code/server/tmw/mobdb.py
@@ -0,0 +1,173 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import math
+import os
+import re
+
+from code.configutils import isHaveData, writeCondField2, writeStartBlock, writeEndBlock, writeIntField, writeStrField, writeFieldArr, writeIntField2, writeFieldList, writeSubField
+from code.fileutils import readFile
+
+def getMobDbFile(srcDir):
+ files = os.listdir(srcDir)
+ for srcFile in files:
+ if srcFile.find("mob_db") >= 0:
+ yield srcFile
+
+def replaceStr(line):
+ vals = [
+ ("lanternaJack", "LanternaJack"),
+ ("foice", "Foice"),
+ ("BlueFairy", "BlueFairyMob"),
+ ("RedFairy", "RedFairyMob"),
+ ("GreenFairy", "GreenFairyMob"),
+ ("Scorpion", "ScorpionMob"),
+ ("Tritan", "TritanMob"),
+ ("Ukar", "UkarMob"),
+ ];
+
+ for val in vals:
+ line = line.replace(val[0], val[1]);
+ return line
+
+def convertMobDb(items):
+ srcDir = "oldserverdata/world/map/db/"
+ dstFile = "newserverdata/db/re/mob_db.conf"
+ fieldsSplit = re.compile(",")
+ tpl = readFile("templates/mob_db.tpl")
+ with open(dstFile, "w") as w:
+ w.write(tpl)
+ for srcFile in getMobDbFile(srcDir):
+ with open(srcDir + srcFile, "r") as r:
+ for line in r:
+ if len(line) < 2 or line[:2] == "//" or line[:1] == "#":
+ w.write(line)
+ continue
+ line = replaceStr(line)
+ rows = fieldsSplit.split(line)
+ for f in xrange(0, len(rows)):
+ rows[f] = rows[f].strip()
+ try:
+ val = int(rows[23])
+ if val < 20:
+ rows[23] = "20"
+ except:
+ None
+
+ # Experience and Job experience, following *tmw-eathena*/src/map/mob.c
+ calc_exp = 0
+
+ if rows[6] == "0":
+ if int(rows[4]) <= 1:
+ calc_exp = 1
+
+ mod_def = 100 - int(rows[11])
+
+ if mod_def == 0:
+ mod_def = 1
+
+ effective_hp = ((50 - int(rows[18])) * int(rows[4]) / 50) + (2 * int(rows[18]) * int(rows[4]) / mod_def)
+ attack_factor = (int(rows[9]) + int(rows[10]) + int(rows[13]) / 3 + int(rows[17]) / 2 + int(rows[18])) * (1872 / int(rows[26])) / 4
+ dodge_factor = (int(rows[3]) + int(rows[14]) + int(rows[18]) / 2)**(4 / 3)
+ persuit_factor = (3 + int(rows[8])) * (int(rows[24]) % 2) * 1000 / int(rows[25])
+ aggression_factor = 1
+
+ if False:
+ aggression_factor = 10 / 9
+
+ base_exp_rate = 100 # From *tmw-eathena-data*/conf/battle_athena.conf
+
+ calc_exp = int(math.floor(effective_hp * (math.sqrt(attack_factor) + math.sqrt(dodge_factor) + math.sqrt(persuit_factor) + 55)**3 * aggression_factor / 2000000 * base_exp_rate / 100))
+
+ if calc_exp < 1:
+ calc_exp = 1
+ else:
+ calc_exp = rows[6]
+
+ w.write("{\n")
+ writeIntField(w, "Id", rows[0])
+ writeStrField(w, "SpriteName", rows[1])
+ if (rows[2] != rows[1]):
+ writeStrField(w, "Name", rows[2])
+ else:
+ writeStrField(w, "Name", "The %s" % rows[2])
+ writeIntField(w, "Lv", rows[3])
+ writeIntField(w, "Hp", rows[4])
+ writeIntField(w, "Sp", rows[5])
+ writeIntField(w, "Exp", calc_exp)
+ writeIntField(w, "JExp", rows[7])
+ writeIntField(w, "AttackRange", rows[8])
+ writeFieldArr(w, "Attack", rows[9], rows[10])
+ writeIntField(w, "Def", rows[11])
+ writeIntField(w, "Mdef", rows[12])
+ writeStartBlock(w, "Stats")
+ writeIntField2(w, "Str", rows[13])
+ writeIntField2(w, "Agi", rows[14])
+ writeIntField2(w, "Vit", rows[15])
+ writeIntField2(w, "Int", rows[16])
+ writeIntField2(w, "Dex", rows[17])
+ writeIntField2(w, "Luk", rows[18])
+ writeEndBlock(w)
+ writeIntField(w, "ViewRange", rows[19])
+ writeIntField(w, "ChaseRange", 10)
+ writeIntField(w, "Size", rows[21])
+ writeIntField(w, "Race", rows[22])
+ writeFieldList(w, "Element", int(rows[23]) % 10, int(rows[23]) / 20)
+ mode = int(rows[24], 0)
+ if mode != 0:
+ writeStartBlock(w, "Mode")
+ writeCondField2(w, mode & 0x0001, "CanMove")
+ writeCondField2(w, mode & 0x0002, "Looter")
+ writeCondField2(w, mode & 0x0004, "Aggressive")
+ writeCondField2(w, mode & 0x0008, "Assist")
+ writeCondField2(w, mode & 0x0010, "CastSensorIdle")
+ writeCondField2(w, mode & 0x0020, "Boss")
+ writeCondField2(w, mode & 0x0040, "Plant")
+ writeCondField2(w, mode & 0x0080, "CanAttack")
+ writeCondField2(w, mode & 0x0100, "Detector")
+ writeCondField2(w, mode & 0x0200, "CastSensorChase")
+ writeCondField2(w, mode & 0x0400, "ChangeChase")
+ writeCondField2(w, mode & 0x0800, "Angry")
+ writeCondField2(w, mode & 0x1000, "ChangeTargetMelee")
+ writeCondField2(w, mode & 0x2000, "ChangeTargetChase")
+ writeCondField2(w, mode & 0x4000, "TargetWeak")
+ writeCondField2(w, mode & 0x8000, "LiveWithoutMaster")
+ writeEndBlock(w)
+ writeIntField(w, "MoveSpeed", rows[25])
+ writeIntField(w, "AttackDelay", rows[26])
+ writeIntField(w, "AttackMotion", rows[27])
+ writeIntField(w, "DamageMotion", rows[28])
+ writeIntField(w, "MvpExp", rows[45])
+
+ if isHaveData(rows, 47, 3):
+ writeStartBlock(w, "MvpDrops")
+ for f in range(0, 3):
+ value = rows[47 + f * 2]
+ chance = rows[47 + f * 2]
+ if value == "" or value == "0" or chance == "" or chance == "0":
+ continue
+ value = int(value)
+ if value not in items:
+ w.write("// Error: mvp drop with id {0} not found in item db\n".format(value))
+ print("Error: mvp drop with id {0} not found in item db".format(value))
+ else:
+ writeSubField(w, items[value]["name"], chance)
+ writeEndBlock(w)
+ if isHaveData(rows, 29, 10):
+ writeStartBlock(w, "Drops")
+ for f in range(0, 10):
+ value = rows[29 + f * 2]
+ chance = rows[30 + f * 2]
+ if value == "" or value == "0" or chance == "" or chance == "0":
+ continue
+ value = int(value)
+ if value not in items:
+ w.write("// Error: drop with id {0} not found in item db\n".format(value))
+ print("Error: drop with id {0} not found in item db".format(value))
+ else:
+ writeSubField(w, items[value]["name"], chance)
+ writeEndBlock(w)
+ w.write("},\n")
+ w.write(")\n")
diff --git a/hercules/code/server/tmw/mobskilldb.py b/hercules/code/server/tmw/mobskilldb.py
new file mode 100644
index 0000000..7188824
--- /dev/null
+++ b/hercules/code/server/tmw/mobskilldb.py
@@ -0,0 +1,55 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import re
+
+from code.fileutils import readFile
+
+def convertMobSkillDb():
+ srcFile = "oldserverdata/world/map/db/mob_skill_db.txt"
+ dstFile = "newserverdata/db/re/mob_skill_db.txt"
+ fieldsSplit = re.compile(",")
+ notintown = re.compile("notintown")
+ notintownSub = re.compile("notintown,0")
+ with open(srcFile, "r") as r:
+ with open(dstFile, "w") as w:
+ tpl = readFile("templates/mob_skill_db.tpl")
+ w.write(tpl)
+ for line in r:
+ if notintown.search(line):
+ if line[0:2] == "//":
+ line = ''
+ line = notintownSub.sub("myhpltmaxrate,20",line)
+ if len(line) < 2 or line[0:2] == "//":
+ w.write(line)
+ continue
+ rows = fieldsSplit.split(line)
+ if len(rows) < 10:
+ w.write(line)
+ continue
+
+ for f in xrange(0, len(rows)):
+ rows[f] = rows[f].strip()
+
+ w.write("{0},{1},{2},{3},{4},{5},{6},"
+ "{7},{8},{9},{10},{11},{12},{13},"
+ "{14},,,,\n".format(
+ rows[0],
+ rows[1],
+ rows[2],
+ rows[3],
+ rows[4],
+ rows[5],
+ rows[6],
+ rows[7],
+ rows[8],
+ rows[9],
+ rows[10],
+ rows[11],
+ rows[12],
+ rows[13],
+ rows[14]
+ ))
+
diff --git a/hercules/code/server/tmw/npcs.py b/hercules/code/server/tmw/npcs.py
new file mode 100644
index 0000000..c51da78
--- /dev/null
+++ b/hercules/code/server/tmw/npcs.py
@@ -0,0 +1,878 @@
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2014 Evol Online
+# Author: Andrei Karas (4144)
+
+import os
+import re
+
+from code.fileutils import makeDir
+from code.stringutils import stripWindows, stripNewLine
+
+mapsConfFile = "newserverdata/conf/maps.conf"
+if os.path.isfile(mapsConfFile):
+ os.remove(mapsConfFile)
+mapsIndexFile = "newserverdata/db/map_index.txt"
+if os.path.isfile(mapsIndexFile):
+ os.remove(mapsIndexFile)
+npcMainScript = "newserverdata/npc/re/scripts_main.conf"
+mapsIndex = 1
+scriptRe = re.compile("^(((?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<dir>[\d]+))|(?P<function>function)|-)" +
+ "[|](?P<tag>script)[|](?P<name>[^|]+)([|]"
+ "(?P<class>[\d-]+)((,((?P<xs>[\d]+),(?P<ys>[\d]+)))|)|)$")
+
+scriptRe2 = re.compile("^(((?P<map>[^/](.+))[.]gat,([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<dir>[\d]+))|(?P<function>function)|-)" +
+ "[\t](?P<tag>script)[\t](?P<name>[\w#'\\[\\]_ äü.-]+)[\t]"
+ "(((?P<class>[\d-]+)((,((?P<xs>[\d-]+),(?P<ys>[\d-]+)))|)(|,)(|[ \t]))|){(|[ ])$")
+
+shopRe = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<dir>[\d]+)(|,(?P<gender>[\d]+))" +
+ "[|](?P<tag>shop)[|](?P<name>[^|]+)[|]"
+ "(?P<class>[\d-]+),(?P<items>(.+))$")
+
+shopRe2 = re.compile("^(?P<map>[^/](.+))[.]gat,([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<dir>[\d]+)" +
+ "[\t](?P<tag>shop)[\t](?P<name>[^\t]+)[\t]"
+ "(?P<class>[\d]+),(?P<items>(.+))$")
+
+mapFlagRe = re.compile("^(?P<map>[^/](.+))" +
+ "[|](?P<tag>mapflag)[|](?P<name>[\w#']+)(|[|](?P<flag>.*))$")
+
+mapFlagRe2 = re.compile("^(?P<map>[^/](.+))[.]gat" +
+ "[ ](?P<tag>mapflag)[ ](?P<name>[\w#']+)(|[ ](?P<flag>.*))$")
+
+warpRe = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+)[|]"
+ "(?P<tag>warp)[|](?P<name>[^|]+)[|](?P<xs>[\d-]+),(?P<ys>[\d-]+),(?P<targetmap>[^/](.+)),([ ]*)(?P<targetx>[\d]+),([ ]*)(?P<targety>[\d]+)$")
+warpRe2 = re.compile("^(?P<map>[^/](.+))[.]gat,([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+)([\t]+)"
+ "(?P<tag>warp)[\t](?P<name>[^\t]+)([\t]+)(?P<xs>[\d-]+),(?P<ys>[\d-]+),(?P<targetmap>[^/](.+))[.]gat,([ ]*)(?P<targetx>[\d]+),([ ]*)(?P<targety>[\d]+)$")
+warpRe3 = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+)[|]"
+ "(?P<tag>warp)[|](?P<xs>[\d-]+),(?P<ys>[\d-]+),(?P<targetmap>[^/](.+)),([ ]*)(?P<targetx>[\d]+),([ ]*)(?P<targety>[\d]+)$")
+
+monsterRe = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<xs>[\d-]+),(?P<ys>[\d-]+)[|]"
+ "(?P<tag>monster)[|](?P<name>[^|]+)[|]"
+ "(?P<class>[\d]+),(?P<num>[\d]+),(?P<delay1>[\d]+)ms,(?P<delay2>[\d]+)ms(|,(?P<label>[\w+-:#]+))$")
+
+monsterRe2 = re.compile("^(?P<map>[^/](.+))[.]gat,([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<xs>[\d-]+),(?P<ys>[\d-]+)\t"
+ "(?P<tag>monster)[\t](?P<name>[\w#' ]+)([\t]+)"
+ "(?P<class>[\d]+),(?P<num>[\d]+),(?P<delay1>[\d]+),(?P<delay2>[\d]+)(|,(?P<label>[\w+-:#]+))$")
+
+setRe = re.compile("^(?P<space>[ ]+)set[ ](?P<var>[^,]+),([ ]*)(?P<val>[^;]+);$");
+
+class ScriptTracker:
+ pass
+
+def createMainScript():
+ with open(npcMainScript, "w") as w:
+ w.write("npc: npc/functions/main.txt\n")
+ w.write("import: npc/scripts.conf\n")
+
+def convertNpcs(items, npcIds):
+ processNpcDir("oldserverdata/world/map/npc/", "newserverdata/npc/", items, npcIds)
+
+def processNpcDir(srcDir, dstDir, items, npcIds):
+ makeDir(dstDir)
+ files = os.listdir(srcDir)
+ for file1 in files:
+ if file1[0] == '.':
+ continue
+ srcPath = os.path.abspath(srcDir + os.path.sep + file1)
+ dstPath = os.path.abspath(dstDir + os.path.sep + file1)
+ if not os.path.isfile(srcPath):
+ processNpcDir(srcPath, dstPath, items, npcIds)
+ else:
+ if file1[-5:] == ".conf" or file1[-4:] == ".txt":
+ processNpcFile(srcPath, dstPath, items, npcIds)
+
+def processNpcFile(srcFile, dstFile, items, npcIds):
+# print "file: " + srcFile
+ tracker = ScriptTracker()
+ tracker.insideScript = False
+ tracker.items = items
+ tracker.npcIds = npcIds
+ with open(srcFile, "r") as r:
+ with open(dstFile, "w") as w:
+ tracker.w = w
+ for line in r:
+ line = stripWindows(line)
+ tracker.line = line
+ res = convertTextLine(tracker)
+ if res:
+ w.write(tracker.line)
+
+def convertTextLine(tracker):
+ line = tracker.line
+ if line[:5] == "map: ":
+ processScriptMapLine(line)
+ return False
+
+ if len(line) >= 2 and line[0:2] == "//":
+ return False
+
+ if line == "};\n":
+ tracker.w.write("}\n");
+ return False
+
+ idx = line.find("|script|")
+ if idx <= 0:
+ idx = line.find("\tscript\t")
+ if idx >= 0:
+ processScript(tracker)
+ return False
+ idx = line.find("|shop|")
+ if idx <= 0:
+ idx = line.find("\tshop\t")
+ if idx >= 0:
+ processShop(tracker)
+ return False
+ idx = line.find("|monster|")
+ if idx <= 0:
+ idx = line.find("\tmonster\t")
+ if idx >= 0:
+ processMonster(tracker)
+ return False
+ idx = line.find("|warp|")
+ if idx <= 0:
+ idx = line.find("\twarp\t")
+ if idx >= 0:
+ processWarp(tracker)
+ return False
+ idx = line.find("|mapflag|")
+ if idx <= 0:
+ idx = line.find(".gat mapflag ")
+ if idx >= 0:
+ processMapFlag(tracker)
+ return False
+ processStrReplace(tracker)
+ return False
+
+def processScriptMapLine(line):
+ global mapsIndex
+ line = stripNewLine(line)
+ if line[-4:] == ".gat":
+ line = line[:-4]
+ with open(mapsConfFile, "a") as w:
+ w.write(line + "\n")
+
+ with open(mapsIndexFile, "a") as w:
+ w.write("{0} {1}\n".format(line[5:], mapsIndex))
+ mapsIndex = mapsIndex + 1
+
+def writeScript(w, m, npcIds):
+ try:
+ if m.group("function") != None:
+ isFunction = True
+ else:
+ isFunction = False
+ except:
+ isFunction = False
+
+ if isFunction:
+ w.write("function");
+ elif m.group("x") == None or (m.group("x") == 0 and m.group("y") == 0): # float npc
+ w.write("-")
+ else:
+ w.write("{0},{1},{2},{3}".format(m.group("map"), m.group("x"), m.group("y"), m.group("dir")))
+ if isFunction:
+ funcName = m.group("name")
+ if funcName == "DailyQuestPoints":
+ funcName = "DailyQuestPointsFunc"
+ w.write("\t{0}\t{1}\t".format(m.group("tag"), funcName));
+ else:
+ class_ = m.group("class")
+ if class_ == "0": # hidden npc
+ class_ = 32767
+ elif class_ == None:
+ class_ = -1;
+ else:
+ class_ = int(class_)
+# if class_ > 125 and class_ <= 400:
+# class_ = class_ + 100
+ npcIds.add(int(class_))
+ if class_ == -1:
+ class_ = "MINUS1"
+ w.write("\t{0}\t{1}\tNPC{2}".format(m.group("tag"), m.group("name"), class_));
+
+def processScript(tracker):
+ line = tracker.line[:-1]
+ w = tracker.w
+
+ m = scriptRe.search(line)
+ if m == None:
+ m = scriptRe2.search(line)
+ if m == None:
+ print "error in parsing: " + line
+ w.write("!!!error parsing line")
+ w.write(line)
+ return
+# print "source=" + line
+# print "map={0} x={1} y={2} dir={3} tag={4} name={5} class={6}, xs={7}, ys={8}".format(
+# m.group("map"), m.group("x"), m.group("y"), m.group("dir"),
+# m.group("tag"), m.group("name"), m.group("class"), m.group("xs"), m.group("ys"))
+ # debug
+
+ try:
+ if m.group("function") != None:
+ isFunction = True
+ else:
+ isFunction = False
+ except:
+ isFunction = False
+
+ writeScript(w, m, tracker.npcIds)
+
+ if m.group("xs") != None:
+ w.write(",{0},{1}".format(m.group("xs"), m.group("ys")));
+
+ if isFunction == False:
+ w.write(",{\n");
+ else:
+ w.write("{\n");
+
+def itemsToShop(tracker, itemsStr):
+ itemsSplit = re.compile(",")
+ itemsSplit2 = re.compile(":")
+ itemsDict = tracker.items
+ outStr = ""
+ items = itemsSplit.split(itemsStr)
+ for str2 in items:
+ parts = itemsSplit2.split(str2)
+ if len(parts) != 2:
+ print "Wrong shop item name {0}: {1}".format(str2, itemsStr)
+ continue
+ if parts[1][0] == "*":
+ parts[1] = str((int(parts[1][1:]) * int(itemsDict[parts[0].strip()]['buy'])))
+ if outStr != "":
+ outStr = outStr + ","
+ itemName = parts[0].strip()
+ if itemName in itemsDict:
+ outStr = outStr + itemsDict[itemName]['id'] + ":" + parts[1]
+ else:
+ print "Wrong item name in shop: {0}".format(itemName)
+ return outStr
+
+def processShop(tracker):
+ line = tracker.line
+ w = tracker.w
+
+ m = shopRe.search(line)
+ if m == None:
+ m = shopRe2.search(line)
+ if m == None:
+ print "error in parsing: " + line
+ w.write("!!!error parsing line")
+ w.write(line)
+ return
+
+# print "source=" + line[:-1]
+# print "map={0} x={1} y={2} dir={3} tag={4} name={5} class={6} items={7}".format(
+# m.group("map"), m.group("x"), m.group("y"), m.group("dir"),
+# m.group("tag"), m.group("name"), m.group("class"), m.group("items"))
+
+ writeScript(w, m, tracker.npcIds)
+ w.write("," + itemsToShop(tracker, m.group("items")) + "\n")
+
+def processMapFlag(tracker):
+ line = tracker.line
+ w = tracker.w
+
+ m = mapFlagRe.search(line)
+ if m == None:
+ m = mapFlagRe2.search(line)
+ if m == None:
+ print "error in parsing: " + line
+ w.write("!!!error parsing line")
+ w.write(line)
+ return
+# print "source=" + line[:-1]
+# print "map={0} tag={1} name={2} flag={3}".format(
+# m.group("map"), m.group("tag"), m.group("name"), m.group("flag"))
+
+ if m.group("name") == "town" or m.group("name") == "resave":
+ w.write("//")
+ w.write("{0}\t{1}\t{2}".format(m.group("map"), m.group("tag"), m.group("name")))
+ if m.group("flag") == None:
+ w.write("\n")
+ else:
+ w.write("\t{0}\n".format(m.group("flag")))
+
+def processWarp(tracker):
+ line = tracker.line
+ w = tracker.w
+ m = warpRe.search(line)
+ noName = False
+ if m == None:
+ m = warpRe2.search(line)
+ if m == None:
+ m = warpRe3.search(line)
+ noName = True
+ if m == None:
+ print "error in parsing: " + line
+ w.write("!!!error parsing line")
+ w.write(line)
+ return
+
+ if noName == True:
+ warpName = "{0}_{1}_{2}".format(m.group("map"), m.group("x"), m.group("y"))
+ else:
+ warpName = m.group("name")
+
+# print "source=" + line[:-1]
+# print "map={0} xy={1},{2} tag={3} name={4} xs={5} ys={6} target: map={7} xy={8},{9}".format(
+# m.group("map"), m.group("x"), m.group("y"), m.group("tag"), warpName, m.group("xs"), m.group("ys"), m.group("targetmap"), m.group("targetx"), m.group("targety"))
+
+ xs = int(m.group("xs"))
+ ys = int(m.group("ys"))
+ if xs < 0:
+ xs = 0
+ if ys < 0:
+ ys = 0
+ w.write("{0},{1},{2},{3}\t{4}\t{5}\t{6},{7},{8},{9},{10}\n".format(
+ m.group("map"), m.group("x"), m.group("y"), "0", m.group("tag"), warpName,
+ xs, ys, m.group("targetmap"), m.group("targetx"), m.group("targety")))
+
+
+def processMonster(tracker):
+ line = tracker.line
+ w = tracker.w
+ m = monsterRe.search(line)
+ if m == None:
+ m = monsterRe2.search(line)
+ if m == None:
+ print "error in parsing: " + line
+ w.write("!!!error parsing line")
+ w.write(line)
+ return
+
+# print "source=" + line[:-1]
+# print ("map={0} xy={1},{2} xs={3} ys={4} tag={5} name={6} class={7} " +
+# "num={8} delays={9},{10}, label={11}").format(
+# m.group("map"), m.group("x"), m.group("y"), m.group("xs"), m.group("ys"),
+# m.group("tag"), m.group("name"), m.group("class"),
+# m.group("num"), m.group("delay1"), m.group("delay2"), m.group("label"))
+
+ if m.group("label") != None:
+ label = "," + m.group("label")
+ else:
+ label = ""
+ w.write("{0},{1},{2},{3},{4}\t{5}\t{6}\t{7},{8},{9},{10}{11}\n".format(m.group("map"),
+ m.group("x"), m.group("y"), m.group("xs"), m.group("ys"),
+ m.group("tag"), m.group("name"),
+ m.group("class"), m.group("num"), m.group("delay1"), m.group("delay2"), label))
+
+
+def processStrReplace(tracker):
+ line = tracker.line
+ w = tracker.w
+ if line == "{\n":
+ return
+ vals = [
+ ("setskill ", "addtoskill "),
+ ("zeny", "Zeny"),
+ ("sc_poison", "SC_POISON"),
+ ("sc_slowpoison", "SC_SLOWPOISON"),
+ ("sex", "Sex"),
+ ("SEX", "Sex"),
+
+ (".gat", ""),
+ ("Bugleg", "BugLeg"),
+ ("set BugLeg, 0;", "//set BugLeg, 0;"),
+ ("set CaveSnakeLamp, 0;", "//set CaveSnakeLamp, 0;"),
+ ("set Class, @BaseClass;", "//set Class, @BaseClass;"),
+ ("goto_Exit;", "goto L_Exit;"),
+ ("if @spants_state < 7 goto", "if(@spants_state < 7) goto"),
+ ("isdead()", "ispcdead()"),
+ ("changeSex", "changecharsex()"),
+ ("getpartnerid2()", "getpartnerid()"),
+ ("getpartnerid2(0)", "getpartnerid()"),
+ ("getgmlevel(0)", "getgmlevel()"),
+ ("if @beer_count > 4", "if (@beer_count > 4)"),
+ ("if !(@Q_status)", "if (!(@Q_status))"),
+ ("if isin(\"021-1\", 130, 120, 140, 125) ", "if (isin(\"021-1\", 130, 120, 140, 125)) "),
+ ("if divorce(0) goto L_", "if (divorce()) goto L_"),
+
+ ("getmap()", "getmapname()"),
+ ("L_end", "L_End"),
+ ("gmcommand", "atcommand"),
+ ("MF_NOSAVE", "mf_nosave"),
+ ("S_update_var", "S_Update_Var"),
+ ("L_teach", "L_Teach"),
+ ("L_focus", "L_Focus"),
+ ("L_unfocus", "L_Unfocus"),
+ ("L_main", "L_Main"),
+ ("L_next", "L_Next"),
+ ("L_close", "L_Close"),
+ ("@NpcName$", "@npcname$"),
+ ("@npcName$", "@npcname$"),
+ ("@cost", "@Cost"),
+ ("@TEMP", "@temp"),
+ ("L_Menuitems", "L_MenuItems"),
+ ("L_no_item", "L_No_Item"),
+ ("L_no_water", "L_No_Water"),
+ ("L_NOT_ENOUGH", "L_No_Water"),
+ ("L_bye", "L_Bye"),
+ ("L_NOHELP", "L_NoHelp"),
+ ("L_Eyepatch", "L_EyePatch"),
+ ("@PC_STAMINA", "@pc_stamina"),
+ ("L_magic", "L_Magic"),
+ ("L_cont", "L_Cont"),
+ ("L_accept", "L_Accept"),
+ ("L_no_event", "L_No_Event"),
+ ("L_event_done", "L_Event_Done"),
+ ("L_nobeer", "L_NoBeer"),
+ ("L_iron", "L_Iron"),
+ ("L_sulphur", "L_Sulphur"),
+ ("L_red", "L_Red"),
+ ("L_yellow", "L_Yellow"),
+ ("L_green", "L_Green"),
+ ("L_orange", "L_Orange"),
+ ("L_pink", "L_Pink"),
+ ("L_purple", "L_Purple"),
+ ("L_question", "L_Question"),
+ ("L_quest", "L_Quest"),
+ ("L_dead", "L_Dead"),
+ ("L_menu", "L_Menu"),
+ ("L_give", "L_Give"),
+ ("@Items$", "@items$"),
+ ("@menuItems$", "@menuitems$"),
+ ("L_Teach_initial", "L_Teach_Initial"),
+ ("L_finish", "L_Finish"),
+ ("L_No_ash", "L_No_Ash"),
+ ("L_no_ash", "L_No_Ash"),
+ ("L_No_water", "L_No_Water"),
+ ("L_cave", "L_Cave"),
+ ("L_farewell", "L_Farewell2"),
+ ("@Q_forestbow_", "@Q_Forestbow_"),
+ ("L_game", "L_Game"),
+ ("L_good", "L_Good"),
+ ("L_abort", "L_Abort"),
+ ("@menuID", "@menuid"),
+ ("L_NO_ITEM", "L_No_Item"),
+ ("L_HELP", "L_Help"),
+ ("L_Noitem", "L_NoItem"),
+ ("L_No_fur", "L_No_Fur"),
+ ("@EXP", "@Exp"),
+ ("L_water", "L_Water"),
+ ("L_get", "L_Get"),
+ ("L_happy", "L_Happy"),
+ ("L_cheat", "L_Cheat"),
+ ("@Reward_EXP", "@Reward_Exp"),
+ ("@REWARD_EXP", "@Reward_Exp"),
+ ("L_no_money", "L_No_Money"),
+ ("@MinLevel", "@minLevel"),
+ ("L_return", "L_Return"),
+ ("L_intro", "L_Intro"),
+ ("L_full", "L_Full"),
+ ("@minlevel", "@minLevel"),
+ ("@MinLevel", "@minLevel"),
+ ("L_Cleanup", "L_CleanUp"),
+ ("L_Alreadystarted", "L_AlreadyStarted"),
+ ("@amount", "@Amount"),
+ ("L_again", "L_Again"),
+ ("L_no_potion", "L_No_Potion"),
+ ("L_wizard_hat", "L_Wizard_Hat"),
+ ("L_notenough", "L_NotEnough"),
+ ("L_offer", "L_Offer"),
+ ("L_giveup", "L_GiveUp"),
+ ("L_not_ready", "L_Not_Ready"),
+ ("@MobID", "@mobId"),
+ ("@mobID", "@mobId"),
+ ("L_naked", "L_Naked"),
+ ("L_shortcut", "L_Shortcut"),
+ ("L_shirt", "L_Shirt"),
+ ("L_goodjob", "L_GoodJob"),
+ ("L_kill", "L_Kill"),
+ ("L_nothing", "L_Nothing"),
+ ("L_lowlevel", "L_LowLevel"),
+ ("L_MENU", "L_Menu"),
+ ("L_potion", "L_Potion"),
+ ("L_fertig", "L_Fertig"),
+ ("L_exit", "L_Exit"),
+ ("L_fight", "L_Fight"),
+ ("L_start", "L_Start"),
+ ("L_unvollst", "L_Unvollst"),
+ ("L_no_room_for_rings", "L_No_Room_For_Rings"),
+ ("@mask", "@Mask"),
+ ("@MAP$", "@map$"),
+ ("baselevel", "BaseLevel"),
+ ("L_Lifestones_Trade_Missing", "L_Lifestones_TM"),
+ ("L_Caretaker_first_reward", "L_Caretaker_fr"),
+ ("L_NohMask_TravelingTroupe", "L_NohMask_TravT"),
+ ("L_listen_to_a_story_first", "L_listen_to_sf"),
+ ("L_post_ironpowder_option", "L_post_ip_op"),
+ ("L_Sulphur_teach_spell_no", "L_Sulphur_tspell"),
+ ("L_Lifestones_MakeSelf_yes", "L_Lifestones_MSy"),
+ ("L_Lifestones_MakeSelf_no", "L_Lifestones_MSn"),
+ ("L_Caretaker_later_rewards", "L_Caretaker_lr"),
+ ("L_boneknife_quest_completed", "L_boneknife_qc"),
+ ("L_boneknife_quest_tooweak", "L_boneknife_qtw"),
+ ("L_tanktop_insufficient_cloth", "L_tanktop_ic"),
+ ("L_dark_green_q_toolittle", "L_dark_greenqtit"),
+ ("L_about_schools_minimenu", "L_about_sch_mm"),
+ ("L_insufficient_BaseLevel", "L_insuf_BL"),
+ ("L_Teach_Initial_nonature", "L_Teach_Ininn"),
+ ("L_Teach_CheckAdvanceTo2_fail", "L_Teach_CATo2f"),
+ ("L_Levelup2_must_practice", "L_Levelup2_mpr"),
+ ("L_Airlia_intro_mana_loss", "L_Airlia_iml"),
+ ("L_knife_quest_completecheck", "L_knife_q_cc"),
+ ("L_Magic_purify_explained", "L_Magic_pur_exp"),
+ ("L_tanktop_insufficient_Zeny", "L_tanktop_ins_Z"),
+ ("L_monster_oil_knows_recipe", "L_monsteroil_kn_r"),
+ ("L_Teach_CheckAdvanceToLOH", "L_TeachChATLOH"),
+ ("L_knife_quest_missing_stingers", "L_knife_qm_sti"),
+ ("L_Magic_train_tree_backgd", "L_Mag_tr_tr_ba"),
+ ("SUB_pick_one_of_many_items", "SUB_pick_1_m_it"),
+ ("L_about_other_prerequisites", "L_a_o_prereq"),
+ ("L_monster_oil_why_dangerous", "L_monstero_w_dang"),
+ ("L_Teach_LOH_advance_abort0", "L_Teach_LOH_a_a0"),
+ ("L_Teach_LOH_advance_abort1", "L_Teach_LOH_a_a1"),
+ ("L_knife_quest_missing_mushrooms", "L_knife_q_m_mushr"),
+ ("L_Magic_train_sagatha_fail", "L_Magic_tsag_f"),
+ ("L_Q_manaseed_touched_short", "L_Q_manas_tou_sh"),
+ ("L_monster_oil_ingredients", "L_monsoil_ingr"),
+ ("L_snakeskins_completecheck", "L_snakes_comc"),
+ ("L_Magic_train_sagatha_lvl1", "L_Mag_tr_sag_lvl1"),
+ ("L_make_mana_potion_missing", "L_make_m_p_mis"),
+ ("L_monster_oil_where_gold", "L_monoil_wg"),
+ ("L_golden_scorpion_wrestle_intro", "L_gold_scor_wr_i"),
+ ("L_component_quest_missing", "L_comp_q_mis"),
+ ("L_monster_oil_start_brew", "L_monsto_st_br"),
+ ("L_golden_requires_knife_quest_done", "L_gold_req_kn_q_d"),
+ ("LL_student_4_wrong_potion", "L_stud_4_wrong_p"),
+ ("L_monster_oil_missing_gold", "L_monsto_mis_g"),
+ ("L_golden_requires_knife_quest", "L_gold_req_kn_q"),
+ ("LL_Magic_skill_insufficient", "L_Mag_sk_insuf"),
+ ("L_monster_oil_out_of_leaves", "L_monso_oo_lea"),
+ ("L_too_lowlevel_for_stinger", "L_too_lol_f_sti"),
+ ("L_monster_oil_leaf_color", "L_monso_le_co"),
+ ("L_golden_scorpion_over_ask", "L_gold_scor_ov_a"),
+ ("S_monster_oil_random_move", "L_monso_rand_mo"),
+ ("L_golden_scorpion_ask_again", "L_gold_scor_as_ag"),
+ ("L_monster_oil_random_0_lighten", "L_monso_rand_0_li"),
+ ("L_golden_scorpion_wrestle_again", "L_gold_scorp_wre_ag"),
+ ("L_monster_oil_explode_dodge", "L_monso_expl_dod"),
+ ("L_golden_scorpion_wrestle", "L_gold_scorp_wre"),
+ ("L_monster_oil_no_gold_end", "L_monso_no_go_e"),
+ ("L_mopox_cure_", "L_moc_"),
+ ("L_mopox_failed_", "L_mof_"),
+ # fix at same time usage with same name function and variable
+ ("\"DailyQuestPoints\"", "\"DailyQuestPointsFunc\""),
+ # TMW-BR errors
+ ("@cerveja", "@Cerveja"),
+ ("@custo", "@Custo"),
+ ("@genero", "@Genero"),
+ ("@gosmaVerme", "@GosmaVerme"),
+ ("@I", "@i"),
+ ("@valor", "@Valor"),
+
+ ("@peloBranco", "@PeloBranco"),
+ ("@pelobranco", "@PeloBranco"),
+ ("@raiz", "@Raiz"),
+ ("@senha", "@Senha"),
+ ("@garrafaVazia", "@GarrafaVazia"),
+ ("@GAMBOGE", "@Gamboge"),
+ ("@FM$", "@fm$"),
+ ("L_abrir", "L_Abrir"),
+ ("L_Abrir", "L_Abrir"),
+ ("L_acabou", "L_Acabou"),
+ ("L_ACABOU", "L_Acabou"),
+ ("L_Aceita", "L_Aceita"),
+ ("L_aceita", "L_Aceita"),
+ ("L_AceitaCapaceteDeMineiro", "L_AceitaCapMineiro"),
+ ("L_AceitaShortDeAlgodao", "L_AceitaShortAlgodao"),
+ ("L_AceitoFlechasDeFerro", "L_AceitaFlechaFerro"),
+ ("L_AceitoFlechasNormais", "L_AceitaFlechaNormal"),
+ ("L_Aceitou", "L_Aceitou"),
+ ("L_aceitou", "L_Aceitou"),
+ ("L_adicionar_registro_AGE", "L_addreg_AGE"),
+ ("L_adicionar_registro_GP", "L_addreg_GP"),
+ ("L_adicionar_registro_LVL", "L_addreg_LVL"),
+ ("L_Ajuda", "L_Ajuda"),
+ ("L_ajuda", "L_Ajuda"),
+ ("L_ajudaComMaisPresentes2", "L_AjudaMaisPresentes2"),
+ ("L_ajudaComMaisPresentes", "L_AjudaMaisPresentes"),
+ ("L_Apresentacao", "L_Apresentacao"),
+ ("L_apresentacao", "L_Apresentacao"),
+ ("L_Arco", "L_Arco"),
+ ("L_arco", "L_Arco"),
+ ("L_Azul", "L_Azul"),
+ ("L_azul", "L_Azul"),
+ ("L_boneknife_quest_completed", "L_BoneKnife_Completo"),
+ ("L_boneknife_quest_tooweak", "L_BoneKnife_Fraco"),
+ ("L_buscar_e_adicionar_AGE", "L_seekadd_AGE"),
+ ("L_buscar_e_adicionar_GP", "L_seekadd_GP"),
+ ("L_buscar_e_adicionar_LVL", "L_seekadd_LVL"),
+ ("L_buscar_e_selecionar_AGE", "L_seeksel_AGE"),
+ ("L_buscar_e_selecionar_GP", "L_seeksel_GP"),
+ ("L_buscar_e_selecionar_LVL", "L_seeksel_LVL"),
+ ("L_Check", "L_Check"),
+ ("L_CHECK", "L_Check"),
+ ("L_cheio", "L_Cheio"),
+ ("L_CHEIO", "L_Cheio"),
+ ("L_Close", "L_close"),
+ ("L_close", "L_close"),
+ ("L_coelhoProcurandoOvos", "L_CoelhoProcuraOvos"),
+ ("L_ComGrana", "L_ComGrana"),
+ ("L_comgrana", "L_ComGrana"),
+ ("L_comprimenta_conhecendo", "L_CumprimentaSabe"),
+ ("L_Concluida", "L_Concluida"),
+ ("L_concluida", "L_Concluida"),
+ ("L_confirmacao_invalida", "L_Inv_Conf"),
+ ("L_Congratulacoes", "L_Congratulacao"),
+ ("L_congratulacoes", "L_Congratulacao"),
+ ("L_Continua", "L_Continua"),
+ ("L_continua", "L_Continua"),
+ ("L_continua_destransformar", "L_Continua_destransf"),
+ ("L_Continua_destransformar", "L_Continua_destransf"),
+ ("L_continuacao", "L_Continuacao"),
+ ("L_Continuacao", "L_Continuacao"),
+ ("L_controlarNacionalidade", "L_ControlaNacao"),
+ ("L_ControlarNacionalidade", "L_ControlaNacao"),
+ ("L_conversa_com_garotas", "L_ConvesaGarota"),
+ ("L_conversa_com_garotos", "L_ConversaGaroto"),
+ ("L_cor", "L_Cor"),
+ ("L_Cor", "L_Cor"),
+ ("L_Curar", "L_Curar"),
+ ("L_curar", "L_Curar"),
+ ("L_dark_green_q_explain2", "L_VerdeEscuro_qexp2"),
+ ("L_dark_green_q_explain", "L_VerdeEscuro_qexp"),
+ ("L_dark_green_q_guess_0", "L_VerdeEscuro_qguess"),
+ ("L_dark_green_q_noslime", "L_VerdeEscuro_noslim"),
+ ("L_dark_green_q_toolittle", "L_VerdeEscuro_pouco"),
+ ("L_dark_green_q_toomuch", "L_VerdeEscuro_muito"),
+ ("L_dep_tudo", "L_Dep_Tudo"),
+ ("L_dep_Tudo", "L_Dep_Tudo"),
+ ("L_DesistenteSelecionado", "L_DesistSel"),
+ ("L_Desistir", "L_Desistir"),
+ ("L_desistir", "L_Desistir"),
+ ("L_desistir_de_assinar2", "L_DesistirAssinar2"),
+ ("L_DICA", "L_Dica"),
+ ("L_Dica", "L_Dica"),
+ ("L_dica", "L_Dica"),
+ ("L_Encontrei", "L_Encontrei"),
+ ("L_encontrei", "L_Encontrei"),
+ ("L_End", "L_End"),
+ ("L_end", "L_end"),
+ ("L_engana_player_novamente", "L_Engana2"),
+ ("L_EQUIP", "L_Equip"),
+ ("L_Equip", "L_Equip"),
+ ("L_ErrouPalavrasMagicas", "L_ErrouMagia2"),
+ ("L_explicacao", "L_Explicacao"),
+ ("L_Explicacao", "L_Explicacao"),
+ ("L_ExplicacaoCausaCrise", "L_ExplicacaoCrise"),
+ ("L_Explicar", "L_Explicar"),
+ ("L_explicar", "L_Explicar"),
+ ("L_fala2", "L_Fala2"),
+ ("L_Fala2", "L_Fala2"),
+ ("L_Fala", "L_Fala"),
+ ("L_fala", "L_Fala"),
+ ("L_falasRestauracaoErro", "L_FalaRestauraErro"),
+ ("L_Falta", "L_Falta"),
+ ("L_falta", "L_Falta"),
+ ("L_falta_ovos_novamente", "L_FaltaOvos2"),
+ ("L_Fechar", "L_Fechar"),
+ ("L_fechar", "L_Fechar"),
+ ("L_Fim", "L_Fim"),
+ ("L_fim", "L_Fim"),
+ ("L_FIM", "L_Fim"),
+ ("L_FimListaDesconectados", "L_FimListaOff"),
+ ("L_Fraco", "L_Fraco"),
+ ("L_fraco", "L_Fraco"),
+ ("L_FRACO", "L_Fraco"),
+ ("L_GanhaPartyParticipar", "L_GanhaPartyP"),
+ ("L_golden_requires_knife_quest", "L_Ouroreq_Knife_q"),
+ ("L_golden_requires_knife_quest_done", "L_Ouroreq_Kinfe_ok"),
+ ("L_golden_scorpion_ask_again", "L_EscorpOuro_again"),
+ ("L_golden_scorpion_over_ask", "L_EscorpOuro_overask"),
+ ("L_golden_scorpion_wrestle", "L_EscorpOuro_Wrest"),
+ ("L_golden_scorpion_wrestle_again", "L_EscorpOuro_Wrest2"),
+ ("L_golden_scorpion_wrestle_intro", "L_EscorpOuro_WerestI"),
+ ("L_HistoriaAdagaBoneClaide", "L_HistoriaAdagaBC"),
+ ("L_Info", "L_Info"),
+ ("L_info", "L_Info"),
+ ("L_iniciaQuest", "L_IniciaQuest"),
+ ("L_IniciaQuest", "L_IniciaQuest"),
+ ("L_Inicio", "L_Inicio"),
+ ("L_inicio", "L_Inicio"),
+ ("L_Inicio_Segunda_Parte", "L_Inicio_P2"),
+ ("L_INSUF", "L_Insuf"),
+ ("L_insuf", "L_Insuf"),
+ ("L_Introfloresta", "L_IntroFloresta"),
+ ("L_introFloresta", "L_IntroFloresta"),
+ ("L_introfloresta", "L_IntroFloresta"),
+ ("L_itens", "L_Itens"),
+ ("L_Itens", "L_Itens"),
+ ("L_jaParticipandoPartida", "L_JaPartPart"),
+ ("L_knife_quest_completecheck", "L_Knife_CompCheck"),
+ ("L_knife_quest_missing_mushrooms", "L_Knife_MissMush"),
+ ("L_knife_quest_missing_mushrooms_2", "L_Knife_MissMush2"),
+ ("L_knife_quest_missing_stingers", "L_Knife_MissSting"),
+ ("L_knife_quest_missing_stingers_2", "L_Knife_MissSting2"),
+ ("L_limpar", "L_Limpar"),
+ ("L_Limpar", "L_Limpar"),
+ ("L_lista", "L_Lista2"),
+ ("L_listen_to_a_story_first", "L_ListenStory"),
+ ("L_longe", "L_Longe"),
+ ("L_LONGE", "L_Longe"),
+ ("L_loop_buscar_desconectados", "L_LoopOff"),
+ ("L_loop_buscar_lutadores2", "L_LoopLutador2"),
+ ("L_loop_buscar_lutadores", "L_LoopLutador"),
+ ("L_main_menu_post_setzer", "L_MM_PostSetzer"),
+ ("L_maisDoces //< pede o dobro de itens e dá o dobro de XP.", "L_MaisDoces //< pede o dobro de itens e dá o dobro de XP."),
+ ("L_Menu", "L_Menu"),
+ ("L_menu", "L_Menu"),
+ ("L_menuGM", "L_MenuGM"),
+ ("L_menugm", "L_MenuGM"),
+ ("L_MenuGM", "L_MenuGM"),
+ ("L_Menugm", "L_MenuGM"),
+ ("L_MenuItens", "L_MenuItens"),
+ ("L_menuItens", "L_MenuItens"),
+ ("L_missaoCogumeloCompleta", "L_MissCog_Ok"),
+ ("L_missaoCordaPescador1", "L_MissCorda_1"),
+ ("L_missaoCordaPescador2", "L_MissCorda_2"),
+ ("L_missaoEscudoMadeira1", "L_MissEscudMad_1"),
+ ("L_missaoEscudoMadeira2", "L_MissEscudMad_2"),
+ ("L_missaoMadeiraResistente", "L_MissMadeiraR"),
+ ("L_missaoMadeiraResistenteCompleta", "L_MissMadeiraR_Ok"),
+ ("L_missaoMaisPresentesCompleta", "L_MissMaisPresenteOK"),
+ ("L_missaoPocaoQueimadura", "L_MissPotQueim"),
+ ("L_missaoPresentesCompleta", "L_MissPresenteOk"),
+ ("L_MOBS_queimaduraEscorpiao", "L_MOB_QueimEscorp"),
+ ("L_nada", "L_Nada2"),
+ ("L_nao", "L_Nao2"),
+ ("L_naoPode", "L_NaoPode"),
+ ("L_naoSei", "L_NaoSei"),
+ ("L_naotenho", "L_NaoTenho"),
+ ("L_Naotenho", "L_NaoTenho"),
+ ("L_naoTrouxe", "L_NaoTrouxe"),
+ ("L_naotrouxe", "L_NaoTrouxe"),
+ ("L_Naotrouxe", "L_NaoTrouxe"),
+ ("L_novaPartida", "L_NovaPartida2"),
+ ("L_NovaPartida", "L_NovaPartida"),
+ ("L_novorecordindividual", "L_NovoRecordSeu"),
+ ("L_obrigado", "L_Obrigado2"),
+ ("L_obsidian_spork_intro", "L_ObsidianSporkIntro"),
+ ("L_OK", "L_Ok2"),
+ ("L_ok", "L_Ok3"),
+ ("L_onde", "L_Onde"),
+ ("L_opcaoFinalizarPartida", "L_opFimPart"),
+ ("L_opcaoIniciaPartidaErro", "L_opIniPartErro"),
+ ("L_opcaoParticipaJogoErro", "L_opPartJogoErro"),
+ ("L_Participante_Invalido", "L_Partc_Invalido"),
+ ("L_Participante_Perdedor", "L_Partc_Perde"),
+ ("L_Participante_Vencedor", "L_partc_Vence"),
+ ("L_pobre", "L_Pobre"),
+ ("L_porque", "L_Porque"),
+ ("L_possuiFragmento", "L_PossuiFragmento"),
+ ("L_preciso", "L_Preciso"),
+ ("L_PrecoPartyParticipar", "L_PrecoPartyPart"),
+ ("L_presente", "L_Presente"),
+ ("L_PrometeVoltarComGRana", "L_VoltoComGp"),
+ ("L_pronto", "L_Pronto"),
+ ("L_quem", "L_Quem"),
+ ("L_QueroArcoDeCurtoAlcance", "L_ArcoCurto"),
+ ("L_ReexplicaApostaParaCobrir", "L_ExpApostaCobrir"),
+ ("L_ReexplicaApostaParaIniciar", "L_ExpApostaIniciar"),
+ ("L_ret_tudo", "L_Ret_Tudo"),
+ ("L_ret_Tudo", "L_Ret_Tudo"),
+ ("L_retirar", "L_Retirar"),
+ ("L_retorno", "L_Retorno"),
+ ("L_retorno_Doces_Escondidos", "L_Retorno_DoceHid"),
+ ("L_Retorno_Segunda_Parte", "L_Retorno_Part2"),
+ ("L_return", "L_Return"),
+ ("L_rever", "L_Rever"),
+ ("L_rico", "L_Rico"),
+ ("L_saia", "L_Saia"),
+ ("L_salvar", "L_Salvar"),
+ ("L_Segunda_Parte_MaisPirulitos", "L_P2_MaisPirulito"),
+ ("L_Segunda_Parte_NaoPirulito", "L_P2_NaoPirulito"),
+ ("L_Segunda_Parte_Pirulito", "L_P2_Pirulito"),
+ ("L_Segunda_Parte_Satisfeito", "L_P2_Satisfeito"),
+ ("L_selecionar_registro_AGE", "L_selreg_AGE"),
+ ("L_selecionar_registro_GP", "L_selreg_GP"),
+ ("L_selecionar_registro_LVL", "L_selreg_LVL"),
+ ("L_semEspaco", "L_SemEspaco"),
+ ("L_semGrana", "L_SemGrana"),
+ ("L_semgrana", "L_SemGrana"),
+ ("L_semItem", "L_SemItem"),
+ ("L_semItens", "L_SemItens"),
+ ("L_semLevel", "L_SemLevel"),
+ ("L_semlevel", "L_SemLevel"),
+ ("L_semlugar", "L_SemLugar"),
+ ("L_semLugar", "L_SemLugar"),
+ ("L_semLvl", "L_SemLvl"),
+ ("L_semLVL", "L_SemLvl"),
+ ("L_SemLVL", "L_SemLvl"),
+ ("L_set", "L_Set"),
+ ("L_SET", "L_Set"),
+ ("L_ShieldNoLeatherPatch", "L_ShdNoLeathPatch"),
+ ("L_sim2", "L_Sim2"),
+ ("L_sim3", "L_Sim3"),
+ ("L_sim", "L_Sim"),
+ ("L_Nao2trouxe", "L_Nao2Trouxe"),
+ ("L_snakeskins_completecheck", "L_snakeskin_okcheck"),
+ ("L_SugerePesquisaDePreco", "L_PesquisePreco"),
+ ("L_tchau2", "L_Tchau2"),
+ ("L_tchau", "L_Tchau"),
+ ("L_This_shouldn_t_happen", "L_NaoDeviaAcontecer"),
+ ("L_too_lowlevel_for_stinger", "L_Stinger_LvlBaixo"),
+ ("L_verde", "L_Verde"),
+ ("L_verificaMaisPresentes", "L_MaisPresenteCheck"),
+ ("L_VOLTA", "L_Volta"),
+ ("L_voltaCheckIngredientes", "L_VoltaCheckItens"),
+ ("L_voltaComIngredientes", "L_VoltaComItens"),
+ ("L_warp", "L_Warp2"),
+ ("L_minissaia", "L_Minissaia"),
+ ("L_preMenu", "L_PreMenu"),
+ ("L_Regras", "L_regras"),
+ ("S_MOBS_queimaduraEscorpiao", "S_MOBS_QueimEscorp"),
+ ("S_MOBS_queimaduraTartaruga", "S_MOBS_QueimTartaruga"),
+ ("Refinamento \\+\" + (@menu", "Refinamento \" + (@menu"),
+ ("Bom! \Aqui vou eu...", "Bom! Aqui vou eu..."),
+ ("\\:\";", ":\";"),
+ ("if BaseLevel <= 10, set", "if (BaseLevel <= 10) set"),
+ ("\\: Passando", ": Passando"),
+ ("\\o/", "o/"),
+ ("(getgmlevel ==", "(getgmlevel() =="),
+ ("foice", "Foice"),
+ ("lanternaJack", "LanternaJack"),
+ ("0), set @preco, ", "0) set @preco, "),
+ ("255), set @preco, ", "255) set @preco, "),
+ ("L_pass", "L_Pass"),
+ ("Quest_threepwood1", "QUEST_threepwood1"),
+ ("L_no", "L_No"),
+ ("L_askHelp", "L_AskHelp"),
+ ("L_ask", "L_Ask"),
+ ("L_notEnough", "L_NotEnough"),
+ ("L_done", "L_Done"),
+ ("L_toomany", "L_TooMany"),
+ ("L_not_enough_money", "L_Not_enough_money"),
+ ("L_island", "L_Island"),
+ ("if @colorID == 2 ", "if (@colorID == 2) "),
+ ("L_help", "L_Help"),
+ ("L_yes", "L_Yes"),
+ ("if @opacityID == 2 ", "if (@opacityID == 2) "),
+ ("L_NohMask_Accuse_Respond", "L_NohMask_AResp"),
+ ("if @opacityID > 4 ", "if (@opacityID > 4) "),
+ ("if @tmpHairStyle > 0 ", "if (@tmpHairStyle > 0) "),
+ ("if @colorID > 6 ", "if (@colorID > 6) "),
+ ("if @opacityID < 0 ", "if (@opacityID < 0) "),
+ ("if countitem(\"MaggotSlime\") >= 10 goto", "if (countitem(\"MaggotSlime\") >= 10) goto"),
+ ("if @colorID < 0 set", "if (@colorID < 0) set"),
+ ];
+
+ for val in vals:
+ line = line.replace(val[0], val[1]);
+
+ idx = line.find("getmapmobs(")
+ if idx >= 0:
+ idx2 = line.find("\"", idx + len("getmapmobs(") + 1)
+ idx3 = line.find(")", idx + len("getmapmobs(") + 1)
+ if idx2 + 1 == idx3:
+ line = line[:idx2 + 1] + ",\"all\"" + line[idx2 + 1:]
+
+ line = line.replace("getmapmobs(", "mobcount(")
+
+ m = setRe.search(line);
+ if m != None:
+ line = "{0}{1} = {2};\n".format(m.group("space"), m.group("var"), m.group("val"))
+
+ w.write(line)
+