summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hercules/code/server/evol/npcs.py3
-rw-r--r--hercules/code/server/tmw/npcs.py52
2 files changed, 51 insertions, 4 deletions
diff --git a/hercules/code/server/evol/npcs.py b/hercules/code/server/evol/npcs.py
index 2082b23..2d198c1 100644
--- a/hercules/code/server/evol/npcs.py
+++ b/hercules/code/server/evol/npcs.py
@@ -66,7 +66,7 @@ def processNpcFile(srcFile, dstFile, items):
with open(dstFile, "w") as w:
tracker.w = w
for line in r:
- tracker.line = line
+ tracker.line = stripWindows(line)
res = convertTextLine(tracker)
if res:
w.write(tracker.line)
@@ -258,7 +258,6 @@ def processStrReplace(tracker):
w = tracker.w
line = line.replace("setskill ", "addtoskill ")
line = line.replace("zeny", "Zeny")
- line = line.replace("countitem(", "countitemcolor(")
line = line.replace("getclientversion(\"\")", "ClientVersion")
line = line.replace("getclientversion()", "ClientVersion")
line = line.replace("setlang @", "Lang = @")
diff --git a/hercules/code/server/tmw/npcs.py b/hercules/code/server/tmw/npcs.py
index dae9b00..525de7c 100644
--- a/hercules/code/server/tmw/npcs.py
+++ b/hercules/code/server/tmw/npcs.py
@@ -20,20 +20,38 @@ scriptRe = re.compile("^(((?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+
"[|](?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>[\w#' ]+)[|]"
"(?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>[\w#'\\[\\] ]+)[\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]+)$")
+
monsterRe = re.compile("^(?P<map>[^/](.+)),([ ]*)(?P<x>[\d]+),([ ]*)(?P<y>[\d]+),([ ]*)(?P<xs>[\d-]+),(?P<ys>[\d-]+)[|]"
"(?P<tag>monster)[|](?P<name>[\w#' ]+)[|]"
"(?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:
@@ -70,6 +88,7 @@ def processNpcFile(srcFile, dstFile, items):
with open(dstFile, "w") as w:
tracker.w = w
for line in r:
+ line = stripWindows(line)
tracker.line = line
res = convertTextLine(tracker)
if res:
@@ -85,22 +104,32 @@ def convertTextLine(tracker):
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
@@ -152,8 +181,11 @@ def writeScript(w, m):
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)
@@ -162,6 +194,7 @@ def processScript(tracker):
# 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:
@@ -189,11 +222,18 @@ def itemsToShop(tracker, itemsStr):
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 + ","
- outStr = outStr + itemsDict[parts[0].strip()]['id'] + ":" + parts[1]
+ 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):
@@ -202,6 +242,8 @@ def processShop(tracker):
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)
@@ -221,6 +263,8 @@ def processMapFlag(tracker):
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)
@@ -242,6 +286,8 @@ def processWarp(tracker):
w = tracker.w
m = warpRe.search(line)
if m == None:
+ m = warpRe2.search(line)
+ if m == None:
print "error in parsing: " + line
w.write("!!!error parsing line")
w.write(line)
@@ -267,6 +313,8 @@ def processMonster(tracker):
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)
@@ -299,8 +347,8 @@ def processStrReplace(tracker):
("zeny", "Zeny"),
("sc_poison", "SC_POISON"),
("sc_slowpoison", "SC_SLOWPOISON"),
- ("countitem(", "countitemcolor("),
("sex", "Sex"),
+ ("SEX", "Sex"),
(".gat", ""),
("Bugleg", "BugLeg"),