summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authornmaligec <wouldnot@hotmail.com>2011-01-05 00:34:26 -0500
committernmaligec <wouldnot@hotmail.com>2011-01-05 00:34:26 -0500
commited8cac19500c515cae40c1fd4b2d87abd96ae3ba (patch)
tree3136c4b4bac4db3a432384390efcc22f88ff2790 /tools
parent21156bed9c3d6eb3cf66a1e1557f4fc8c87a4194 (diff)
parent1e1e26e1255a487a14ca99c60c3ab51ad3988f9b (diff)
downloadserverdata-ed8cac19500c515cae40c1fd4b2d87abd96ae3ba.tar.gz
serverdata-ed8cac19500c515cae40c1fd4b2d87abd96ae3ba.tar.bz2
serverdata-ed8cac19500c515cae40c1fd4b2d87abd96ae3ba.tar.xz
serverdata-ed8cac19500c515cae40c1fd4b2d87abd96ae3ba.zip
merging updates from previous test repo ta-testing.
Diffstat (limited to 'tools')
-rw-r--r--tools/item_show.py29
-rw-r--r--tools/monster-killing-values.py61
-rw-r--r--tools/showmagicspells.py64
-rwxr-xr-xtools/showvars.py81
4 files changed, 235 insertions, 0 deletions
diff --git a/tools/item_show.py b/tools/item_show.py
new file mode 100644
index 00000000..1e14e773
--- /dev/null
+++ b/tools/item_show.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+#has to be executed in place, this folder
+
+
+def make_items():
+ items_file=open("../db/item_db.txt","r")
+ lines=items_file.readlines()
+ items_file.close();
+
+ items=[]
+ for line in lines:
+ array=line.split(",")
+ if len(array)>6 and not line.startswith("#") and not line.startswith("//"):
+ id=array[0]
+ name=array[1]
+ mbonus=array[10]
+ try:
+ int(mbonus)
+ items+=[(int(mbonus),name)]
+ except:
+ print line
+ return items;
+
+global_items=[]
+global_items=make_items();
+
+global_items.sort()
+for item in global_items:
+ print item
diff --git a/tools/monster-killing-values.py b/tools/monster-killing-values.py
new file mode 100644
index 00000000..9578804e
--- /dev/null
+++ b/tools/monster-killing-values.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+#has to be executed in place, this folder
+
+
+def make_items():
+ items_file=open("../db/item_db.txt","r")
+ lines=items_file.readlines()
+ items_file.close();
+
+ items=[]
+ for line in lines:
+ array=line.split(",")
+ if len(array)>6 and not line.startswith("#") and not line.startswith("//"):
+ id=array[0]
+ sellprize=array[5]
+ try:
+ int(sellprize)
+ items+=[(int(id),int(sellprize))]
+ except:
+ print line
+ return items;
+
+def getvalueof(id):
+ for x in global_items:
+ if x[0]==id:
+ return int(x[1])
+ return 0
+
+def make_mobs():
+ mobfile=open("../db/mob_db.txt","r")
+ lines=mobfile.readlines()
+ mobfile.close();
+
+ mobs=[]
+ for line in lines:
+ array=line.split(",")
+ if len(array)>6 and not line.startswith("#"):
+ id=array[0]
+ name=array[1]
+ print name
+ print array[29:44]
+ sellprize = 0
+ #hardcoded -.- fix it !
+ sellprize += getvalueof(int(array[29]))*int(array[30])
+ sellprize += getvalueof(int(array[31]))*int(array[32])
+ sellprize += getvalueof(int(array[33]))*int(array[34])
+ sellprize += getvalueof(int(array[35]))*int(array[36])
+ sellprize += getvalueof(int(array[37]))*int(array[38])
+ sellprize += getvalueof(int(array[39]))*int(array[40])
+ sellprize += getvalueof(int(array[41]))*int(array[32])
+ sellprize += getvalueof(int(array[43]))*int(array[44])
+ mobs+=[(name,sellprize/1000.0)]
+ return mobs
+
+global_items=[]
+global_items=make_items();
+
+mobs=make_mobs();
+
+for mob in mobs:
+ print mob[1],mob[0]
diff --git a/tools/showmagicspells.py b/tools/showmagicspells.py
new file mode 100644
index 00000000..6909a724
--- /dev/null
+++ b/tools/showmagicspells.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# showmagicspells.py
+#
+# Copyright 2010 Stefan Beller
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+def handle_lines(lines):
+ def getInfo(line, info):
+ sp = line.split(" ")
+ if info in sp:
+ pos = sp.index(info)
+ return sp[pos+2].strip()
+ return ""
+
+ firstline = lines[0].split(" ")
+ pos=firstline.index("SPELL")
+ name= firstline[pos+1]
+ level = getInfo(lines[1],"level")
+ school = getInfo(lines[2],"school")
+
+ #print name,level,school
+ if not school in spells:
+ spells[school]=[]
+ spells[school]+=[(name,level,school)]
+
+def main():
+ fname = "../conf/magic.conf.template"
+ f=open(fname, "r");
+ lines=f.readlines();
+ f.close();
+
+ while lines :
+ line=lines[0]
+ if line.startswith("SPELL"):
+ handle_lines(lines);
+ if line.startswith("# LOCAL SPELL"):
+ handle_lines(lines);
+ if line.startswith("# SPELL"):
+ handle_lines(lines);
+ del lines[0]
+ return 0
+
+spells={}
+main()
+for x in spells:
+ print x
+ for y in spells[x]:
+ print "\t",y[1],y[0];
+
diff --git a/tools/showvars.py b/tools/showvars.py
new file mode 100755
index 00000000..4b3d0cb4
--- /dev/null
+++ b/tools/showvars.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+
+
+# must be started in the npc dir
+
+import os
+import re
+from optparse import OptionParser
+parser = OptionParser()
+parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False,
+ help="show the occurrences of that var", metavar="FILE")
+
+(options, args) = parser.parse_args()
+
+def handleFile(fname):
+ f = open(fname)
+ lines = f.readlines();
+ f.close()
+ for l in lines:
+ #remove comments
+ line = l.split(r"//")[0]
+
+ sp = line.split()
+
+ # no set command?
+ if not "set" in sp:
+ continue
+
+ # ignore those lines printing messages
+ if 'mes "' in line:
+ continue
+
+ #ignore anything before the "set" command:
+ sp = sp[sp.index("set")+1:]
+ line = "".join(sp)
+ endpos = line.find(",")
+
+ #check for comma
+ if endpos>0:
+ #ok its a oneliner, the comma is in the same line:
+ varname = line[0:endpos].strip()
+ if varname.startswith("@"):
+ continue
+ if varname.startswith("$"):
+ continue
+ if varname in allvars:
+ if not fname in allvars[varname]:
+ allvars[varname] += [fname]
+ else:
+ allvars[varname] = [fname]
+ else:
+ # ok error, you need to check manually:
+ print "\tline:\t",line
+
+allvars = {}
+
+print "please check manully for vars in here:"
+os.chdir(".."+os.sep+"npc")
+for tpl in os.walk("."):
+ for fname in tpl[2]:
+ handleFile(tpl[0]+os.sep+fname)
+
+# now check if the variable is not in npc/functions/clear_vars.txt, if so remove it
+checkstring = "." + os.sep + "functions" + os.sep + "clear_vars.txt"
+rm = []
+for var in allvars:
+ if checkstring in allvars[var]:
+ rm += [var]
+
+#now really remove these vars
+for var in rm:
+ del allvars[var]
+
+print "These variables are valid variables of the scripts:"
+for var in allvars:
+ print "\t",var
+ if options.verbose:
+ for fname in allvars[var]:
+ print "\t","\t", fname
+
+print "number of vars:", len(allvars)