#! /usr/bin/env python3 # -*- coding: utf8 -*- # # Copyright (C) 2010-2011 Evol Online # Copyright (C) 2018 TMW-2 # Author: Andrei Karas (4144) # Author: Jesusalva import datetime wikib=open("EleMonsters.html", "w") wikib.write('EleGen File') totalid=0 def printSeparator(): print("--------------------------------------------------------------------------------") def showHeader(): print("TMW2 Ele Generator") print("This stuff analyzes and sorts mobs elementals, races and walkmasks.") ##print "Evol client data validator." print("Run at: " + datetime.datetime.now().isoformat()) ##print "https://gitlab.com/evol/evol-tools/blob/master/testxml/testxml.py" printSeparator() def showFooter(): #pass #printSeparator() print("Done.") Mobs0=[] Mobs1=[] Mobs2=[] Mobs3=[] Mobs4=[] Mobs5=[] Mobs6=[] Mobs7=[] Mobs8=[] Mobs9=[] MobsA=[] SysDrops=[] def fwalk(wmask): if wmask == 'WATER': return '%s' % (wmask) elif wmask == 'AIR': return '%s' % (wmask) elif wmask == 'WALL': return '%s' % (wmask) elif wmask == 'NORMAL' or wmask == 'DEFAULT': return '%s' % (wmask) else: print("Invalid walk mask: "+wmask) exit(1) def WhatRace(rac): rc=rac.race if rc == 0: return "Formless" elif rc == 1: return "Undead" elif rc == 2: return "Brute" elif rc == 3: return "Plant" elif rc == 4: return "Insect" elif rc == 5: return "Fish" elif rc == 6: return "Evil" elif rc == 7: return "SemiHuman" elif rc == 8: return "Angel" elif rc == 9: return "Dragon" elif rc == 10: return "Player" elif rc == 11: return "Boss" elif rc == 12: return "NonBoss" elif rc == 14: return "NonSemiHuman" elif rc == 15: return "NonPlayer" elif rc == 16: return "SemiPlayer" elif rc == 17: return "NonSemiPlayer" else: print("ERROR, INVALID RACE ID: %d (ID: %s)" % (rc, rac.id)) exit(1) def WhatElem(rac): rc=rac.elem tl="ERROR" cl="#F00" if rc == 0: tl,cl="Neutral","#000" elif rc == 1: tl,cl="Water","#00F" elif rc == 2: tl,cl="Earth","#7A0" elif rc == 3: tl,cl="Fire","#F00" elif rc == 4: tl,cl="Wind","#093" elif rc == 5: tl,cl="Nature","#040" elif rc == 6: tl,cl="Holy","#afa" elif rc == 7: tl,cl="Dark","#908" elif rc == 8: tl,cl="Ghost","#404" elif rc == 9: tl,cl="Undead","#440" else: print("ERROR, INVALID ELEM ID: %d (ID: %s)" % (rc, rac.id)) exit(1) return "%s" % (cl, tl) class Mob: def __init__(self): # Basic self.id="0" #self.aegis="UnknownMonster" # SpriteName is not used anywhere, we are using its ID self.name="Unknown Monster Name" self.view="1" # Defensive self.mobpt="0" # Mob Points “Level” self.hp="0" self.xp="0" self.jp="0" self.st="" # Offensive self.atk="[0, 0]" self.range="0" self.move="0" self.delay="0" self.drops=[] # New self.race=-1 self.elem=-1 self.elel=-1 self.walk="NORMAL" def MobAlloc(ab): try: maab=int(ab.elem) except: maab=9901 if maab == 0: Mobs0.append(ab) elif maab == 1: Mobs1.append(ab) elif maab == 2: Mobs2.append(ab) elif maab == 3: Mobs3.append(ab) elif maab == 4: Mobs4.append(ab) elif maab == 5: Mobs5.append(ab) elif maab == 6: Mobs6.append(ab) elif maab == 7: Mobs7.append(ab) elif maab == 8: Mobs8.append(ab) elif maab == 9: Mobs9.append(ab) else: MobsA.append(ab) def testMobs(): global totalid print("Generating Elem-Mob Wiki...") src=open("../../server-data/db/re/mob_db.conf", "r") wikib.write("

EleGen Monster Database

\n") start=False dropper=False x=Mob() # Only for pyflakes2 for a in src: if a == "{\n": if start: MobAlloc(x) else: start=True x=Mob() if " Id:" in a: x.id=stp(a) totalid+=1 if x.id == "ID": continue if " Name:" in a: x.name=stp(a) elif " Hp:" in a: x.hp=stp(a) elif " Lv:" in a: x.mobpt=stp(a) elif " Exp:" in a: x.xp=stp(a) elif " JExp:" in a: x.jp=stp(a) elif " Attack:" in a: x.atk=stp(a) elif " AttackRange:" in a: x.range=stp(a) elif " MoveSpeed:" in a: x.move=stp(a) elif " ViewRange:" in a: x.view=stp(a) elif " AttackDelay:" in a: x.delay=stp(a) elif " Looter: true" in a: x.st+="Lot," elif " Assist: true" in a: x.st+="Ass," elif " Aggressive: true" in a: x.st+="Agr," elif " WalkMask:" in a: x.walk=stp(a) elif " Element:" in a: tmp=stp(a) tmp2=tmp.split(',') try: x.elem=int(tmp2[0]) x.elel=int(tmp2[1]) except: print("Invalid Element for mob %s: %s" % (x.id, tmp)) exit(1) elif " Race:" in a: try: x.race=int(stp(a)) except: print("Invalid Race for mob %s: %s" % (x.id, a)) exit(1) elif 'Drops: ' in a: dropper=True elif dropper and '}' in a: dropper=False elif dropper: x.drops.append(stp(a).split(": ")) # Write last entry MobAlloc(x) writeMob() wikib.write('\n\n|Mode|Desc|\n|----|----|\n') wikib.write('|Lot|Looter|\n') wikib.write('|Ass|Assist|\n') wikib.write('|Agr|Aggressive|\n') src.close() def stp(x): return x.replace('\n', '').replace('|', '').replace('(int, defaults to ', '').replace(')', '').replace('basic experience', '').replace('"','').replace(" ","").replace("\t","").replace('(string', '').replace('Name: ','').replace('Element: ','').replace('Race: ','').replace('AttackDelay: ', '').replace('WalkMask: ','').replace('MoveSpeed: ', '').replace('AttackRange: ', '').replace('ViewRange: ','').replace('Attack: ','').replace('ViewRange: ','').replace('Hp: ','').replace('Id: ','').replace('Lv: ','').replace('view range','').replace('attack range','').replace('move speed','').replace('health','').replace('(int','').replace('attack delay','atk.').replace('(','').replace(')','').replace('WALK_','') def MonsterWrite(tbl): # TODO: Check _mobs files to determine the usual monster density (a misc info to aid adding proper drop specs) wikib.write("\n") wikib.write("\n") for i in sorted(tbl, key=lambda tbl: int(tbl.mobpt)): if i.id == 'ID': continue wikib.write('\n" ) wikib.write("
IDNameMob InfoElegenMisc InfoRewardsDrops
' + i.id +""+ i.name +""+ mb_core(i) +""+ mb_eleg(i) +""+ mbdt('misc', mb_rdmisc(i)) +""+ mbdt('Exp\'s', mb_rdrw(i)) +""+ mbdt('drops', mb_rddrop(i)) +"
\n") wikib.write("\n(↑) Return to top

\n\n") def writeMob(): wikib.write("Total monsters: %d
" % totalid) wikib.write(" ") wikib.write("

Neutral

\n\n") MonsterWrite(Mobs0) wikib.write("

Water

\n\n") MonsterWrite(Mobs1) wikib.write("

Earth

\n\n") MonsterWrite(Mobs2) wikib.write("

Fire

\n\n") MonsterWrite(Mobs3) wikib.write("

Wind

\n\n") MonsterWrite(Mobs4) wikib.write("

Nature

\n\n") MonsterWrite(Mobs5) wikib.write("

Holy

\n\n") MonsterWrite(Mobs6) wikib.write("

Dark

\n\n") MonsterWrite(Mobs7) wikib.write("

Ghost

\n\n") MonsterWrite(Mobs8) wikib.write("

Undead

\n\n") MonsterWrite(Mobs9) wikib.write("

Error

\n\n") MonsterWrite(MobsA) def mbdt(summary, content): return "
%s
" % (content) return "
\ "+summary+"\
"+content+"
" def mb_core(mb): buff="" buff+="Lvl: %s
\n" % (mb.mobpt) buff+="HP: %s
\n" % (mb.hp) buff+="ATK: %s
\n" % (mb.atk) if mb.st != "": buff+="Modes: %s" % (mb.st) return buff def mb_eleg(mb): buff="" buff+="Race: %s
\n" % (WhatRace(mb)) buff+="Walk: %s
\n" % (fwalk(mb.walk)) buff+="Element: %s
\n" % (WhatElem(mb)) return buff def mb_rdmisc(mb): buff="" if "agr" in mb.st.lower(): buff+="View Range: %s\n" % (mb.view) buff+="Attack Range: %s\n" % (mb.range) buff+="AtkDelay: %s ms\n" % (mb.delay) buff+="Move speed: %s ms\n" % (mb.move) buff+="Element Level: %d\n" % (mb.elel) return buff def mb_rdrw(mb): buff="" try: buff+="MobPoints: %d\n" % (int(mb.mobpt)*11/10) except: pass buff+="%s\n" % (mb.xp) buff+="%s\n" % (mb.jp) return buff def mb_rddrop(mb): buff="" for ax in mb.drops: # Ignore disabled drops if ax[0].startswith("//"): continue # Write drop try: buff+=ax[0]+': ' + str(int(ax[1])/100.0) + ' %\n' except IndexError: print("Fatal: invalid %s mob with %s drops" % (mb.name, str(ax))) exit(1) except: print("[Warning] %s incorrect drop: %s" % (mb.name, str(ax))) buff+=ax[0]+': ' + ax[1] + ' ppm\n' # Save to SysDrops SysDrops.append([ax[0], ax[1], mb.name]) return buff showHeader() testMobs() print("Total monsters: %d" % totalid) wikib.write('') wikib.close() #print(str(SysDrops)) showFooter() exit(0)