diff options
Diffstat (limited to 'hercules/code/server')
-rw-r--r-- | hercules/code/server/tmw/itemdb.py | 36 | ||||
-rw-r--r-- | hercules/code/server/tmw/mobdb.py | 34 |
2 files changed, 56 insertions, 14 deletions
diff --git a/hercules/code/server/tmw/itemdb.py b/hercules/code/server/tmw/itemdb.py index eff90cd..c27a06c 100644 --- a/hercules/code/server/tmw/itemdb.py +++ b/hercules/code/server/tmw/itemdb.py @@ -24,7 +24,10 @@ def convertItemDb(): if os.path.isfile(constsFile): os.remove(constsFile) fieldsSplit = re.compile(",") - scriptsSplit = re.compile("{") + scriptsSplit = re.compile("},") + scriptsTextClean = re.compile('([{}])') + scriptsTextComma = re.compile('^,') + scriptsTextColon = re.compile('; ') items = dict() tpl = readFile("templates/item_db.tpl") @@ -48,12 +51,16 @@ def convertItemDb(): rows[f] = rows[f].strip() items[rows[1]] = {'id':rows[0],'buy':rows[4]} + # 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]) writeStrField(w, "Name", rows[2]) - writeIntField(w, "Type", rows[3]) + if rows[3] == "0": + writeIntField(w, "Type", "2") + else: + writeIntField(w, "Type", rows[3]) writeIntField(w, "Buy", rows[4]) writeIntField(w, "Sell", rows[5]) writeIntField(w, "Weight", rows[6]) @@ -83,18 +90,23 @@ def convertItemDb(): writeIntField(w, "Sprite", "0") scripts = "" - for f in xrange(sz, len(rows)): + for f in xrange(17, len(rows)): scripts = scripts + ", " + rows[f] rows = scriptsSplit.split(scripts) - cnt = len(rows) - if cnt > 1: - text = rows[1].strip() - if len(text) > 1: - text = text[:-2] - if text != "": - writeStartScript(w, "Script") - w.write(" {0}\n".format(text)) - writeEndScript(w) + # Needs .split(';') and \n each + UseScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[0]))).strip().split(';') + EquipScript = scriptsTextColon.sub(';',scriptsTextComma.sub('', scriptsTextClean.sub('', rows[1]))).strip().split(';') + # move to for stmt + if len(UseScript) > 1: + writeStartScript(w, "Script") + for uline in UseScript: + w.write(" {0};\n".format(uline)) + writeEndScript(w) + if len(EquipScript) > 1: + writeStartScript(w, "OnEquipScript") + for eline in EquipScript: + w.write(" {0};\n".format(eline)) + writeEndScript(w) w.write("},\n") w.write(")\n") diff --git a/hercules/code/server/tmw/mobdb.py b/hercules/code/server/tmw/mobdb.py index 7e406b1..4c22a34 100644 --- a/hercules/code/server/tmw/mobdb.py +++ b/hercules/code/server/tmw/mobdb.py @@ -3,7 +3,7 @@ # Copyright (C) 2014 Evol Online # Author: Andrei Karas (4144) -import re +import re, math from code.fileutils import * from code.stringutils import * @@ -35,6 +35,36 @@ def convertMobDb(): 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("{0:<5} {1:<15} {2:<16} {3:<16} {4:<5} {5:<5} {6:<5} " "{7:<5} {8:<5} {9:<7} {10:<5} {11:<5} {12:<5} {13:<5} " "{14:<5} {15:<5} {16:<5} {17:<5} {18:<5} {19:<5} {20:<7}" @@ -51,7 +81,7 @@ def convertMobDb(): rows[3] + ",", rows[4] + ",", rows[5] + ",", - rows[6] + ",", + str(calc_exp) + ",", rows[7] + ",", rows[8] + ",", rows[9] + ",", |