#! /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
wikia=open("Items.md", "w")
wikib=open("Monsters.md", "w")
# the TYPEs we use to determine where to pack things
IT_HEALING=[]
IT_ETC=[]
IT_USABLE=[]
IT_AMMO=[]
IT_CARD=[]
IT_PETEGG=[]
IT_WEAPON={ 'HAND_2': [], # TWO HAND (LR)
'HAND_1':[]} # WEAPONS (R)
IT_ARMOR={ 'MISC': [], # FOR FAILURE
'EQP_ACC_L': [], # ACCESSORY LEFT
'EQP_ACC_R': [], # ACCESSORT RIGHT
'EQP_HEAD_MID': [], # CHEST
'EQP_SHOES': [], # FEET
'EQP_GARMENT': [], # GLOVES
'EQP_HEAD_LOW':[], # PANTS
'1024': [], # NECKLACES (should be EQP_COSTUME_HEAD_TOP instead of number)
'2048': [], # RINGS (should be EQP_COSTUME_HEAD_MID instead of number)
'EQP_HEAD_TOP':[], # HATS/HELMETS
'EQP_HAND_L': []} # SHIELDS
def printSeparator():
print("--------------------------------------------------------------------------------")
def showHeader():
print("TMW2 Wiki Generator")
##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.")
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=[]
AggMobs=[]
NrmMobs=[]
def MobAlloc(ab):
if "agr" in ab.st.lower():
AggMobs.append(ab)
else:
NrmMobs.append(ab)
def testMobs():
print("Generating Mob Wiki...")
src=open("../../server-data/db/re/mob_db.conf", "r")
wikib.write("# 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)
elif " 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 'Drops: ' in a:
dropper=True
elif dropper and '}' in a:
dropper=False
elif dropper:
x.drops.append(stp(a))
# 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('(string', '').replace('Name: ','').replace('AttackDelay: ', '').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','')
def writeMob():
wikib.write("\
+ [Aggressive Monsters](#aggressive-monsters)\n\
+ [Normal Monsters](#normal-monsters)\n\n\
")
wikib.write("## Aggressive Monsters\n\n")
wikib.write("
\n")
wikib.write("ID | Name | HP | Atk | Delay | View Range | Misc Info | Rewards | Drops |
\n")
for i in AggMobs:
wikib.write('' +
i.id +" | "+
i.name +" | HP: "+
i.hp +" | Atk: "+
i.atk +" | "+
i.delay +" ms | View: "+
i.view +" | "+
mbdt('misc', mb_rdmisc(i)) +" | "+
mbdt('Exp\'s', mb_rdrw(i)) +" | "+
mbdt('drops', mb_rddrop(i)) +" |
\n"
)
wikib.write("
\n")
wikib.write("\n[(↑) Return to top](#monster-database)\n\n")
wikib.write("## Normal Monsters\n\n")
wikib.write("\n")
wikib.write("ID | Name | HP | Atk | Delay | Misc Info | Rewards | Drops |
\n")
for i in NrmMobs:
wikib.write('' +
i.id +" | "+
i.name +" | HP: "+
i.hp +" | Atk: "+
i.atk +" | "+
i.delay +" ms | "+
mbdt('misc', mb_rdmisc(i)) +" | "+
mbdt('Exp\'s', mb_rdrw(i)) +" | "+
mbdt('drops', mb_rddrop(i)) +" |
\n"
)
wikib.write("
\n")
wikib.write("\n[(↑) Return to top](#monster-database)\n\n")
def mbdt(summary, content):
return "\
"+summary+"
\
"+content+"
"
def mb_rdmisc(mb):
buff=""
buff+="Modes: %s\n" % (mb.st) # TODO: Move to table body
buff+="Attack Range: %s\n" % (mb.range)
buff+="Move speed: %s ms\n" % (mb.move)
return buff
def mb_rdrw(mb):
buff=""
buff+="MobPoints: %s\n" % (mb.mobpt)
buff+="%s\n" % (mb.xp)
buff+="%s\n" % (mb.jp)
return buff
def mb_rddrop(mb):
buff=""
for ax in mb.drops:
buff+=ax+'\n'
return buff
class It:
def __init__(self):
# Basic
self.id="0"
self.aegis="UnknownItem"
self.name="Unknown Item Name"
self.price="0" # Sell price, of course
self.weight="0"
self.type="IT_ETC" # default type
self.loc=""
# Offensive/Defensive
self.atk="0"
self.matk="0"
self.range="0"
self.defs="0"
# Restrictions (EquipLv)
self.lvl="0"
self.drop=True
self.trade=True
self.sell=True
self.store=True
# Special settings
self.rare=False # DropAnnounce
self.script=False
# Script settings
self.minheal="0"
self.maxheal="0"
self.delheal="0"
def ItAlloc(it):
a=it.type
if "IT_HEALING" in a:
IT_HEALING.append(it)
elif "IT_ETC" in a:
IT_ETC.append(it)
elif "IT_USABLE" in a:
IT_USABLE.append(it)
elif "IT_AMMO" in a:
IT_AMMO.append(it)
elif "IT_CARD" in a:
IT_CARD.append(it)
elif "IT_PETEGG" in a:
IT_PETEGG.append(it)
elif "IT_WEAPON" in a:
if "HAND_L" in it.loc or "EQP_ARMS" in it.loc:
IT_WEAPON["HAND_2"].append(it)
elif "HAND_R" in it.loc:
IT_WEAPON["HAND_1"].append(it)
else:
raise Exception("Invalid location for weapon: %s" % it.loc)
elif "IT_ARMOR" in a:
if 'EQP_ACC_L' in it.loc:
IT_ARMOR['EQP_ACC_L'].append(it)
elif 'EQP_ACC_R' in it.loc:
IT_ARMOR['EQP_ACC_R'].append(it)
elif 'EQP_HEAD_MID' in it.loc:
IT_ARMOR['EQP_HEAD_MID'].append(it)
elif 'EQP_SHOES' in it.loc:
IT_ARMOR['EQP_SHOES'].append(it)
elif 'EQP_GARMENT' in it.loc:
IT_ARMOR['EQP_GARMENT'].append(it)
elif 'EQP_HEAD_LOW' in it.loc:
IT_ARMOR['EQP_HEAD_LOW'].append(it)
elif 'EQP_HEAD_TOP' in it.loc:
IT_ARMOR['EQP_HEAD_TOP'].append(it)
elif 'EQP_HAND_L' in it.loc:
IT_ARMOR['EQP_HAND_L'].append(it)
elif '1024' in it.loc:
IT_ARMOR['1024'].append(it)
elif '2048' in it.loc:
IT_ARMOR['2048'].append(it)
else:
raise Exception("Invalid Loc for ID %s: %s" % (it.id, it.loc))
def newItemDB():
print("Generating Item Wiki...")
src=open("../../server-data/db/re/item_db.conf", "r")
x=It()
for a in src:
if a == "{\n":
ItAlloc(x)
x=It()
# sti() block
if " Id:" in a:
x.id=sti(a)
elif " AegisName:" in a:
x.aegis=sti(a)
elif " Name:" in a:
x.name=stin(a)
elif " Sell:" in a:
x.price=sti(a)
elif " Weight:" in a:
x.weight=sti(a)
elif " Type:" in a:
x.type=sti(a)
elif " Loc:" in a:
x.loc=sti(a)
elif " Atk:" in a:
x.atk=sti(a)
elif " Matk:" in a:
x.matk=sti(a)
elif " Range:" in a:
x.range=sti(a)
elif " Def:" in a:
x.defs=sti(a)
elif " EquipLv:" in a:
x.lvl=sti(a)
# Write booleans
elif "DropAnnounce: true" in a:
x.rare=True
elif "nodrop: true" in a:
x.drop=False
elif "notrade: true" in a:
x.trade=False
elif "noselltonpc: true" in a:
x.sell=False
elif "nostorage: true" in a:
x.store=False
elif "Script" in a:
x.script=True
# For healing items
elif "@min" in a:
x.minheal=sti(a)
elif "@max" in a:
x.maxheal=sti(a)
elif "@delay" in a:
x.delheal=sti(a)
# Write last entry
ItAlloc(x)
writeItems()
src.close()
def sti(x):
return x.replace('\n', '').replace('|', '').replace(')', '').replace('Id: ', '').replace('"','').replace(" ","").replace('AegisName: ', '').replace('Name: ','').replace('Sell: ', '').replace('Weight: ', '').replace('Type: ', '').replace('Loc: ', '').replace('Atk: ', '').replace('Matk: ', '').replace('Range: ', '').replace('Def: ', '').replace('EquipLv: ', '').replace(" ", "").replace('@min=','').replace('@max=','').replace('@delay=','').replace(';','')
def stin(x):
return x.replace('\n', '').replace('|', '').replace(')', '').replace('Id: ', '').replace('"','').replace(" ","").replace('Name: ','').replace(';','')
def writeItems():
wikia.write("# Items\n\
+ [Healing Items](#healing-items)\n\
+ [Usable Items](#usable-items)\n\
+ [Generic Items](#generic-items)\n\
+ [Ammo](#ammo)\n\
+ [Cards](#cards)\n\
+ [Pet Eggs](#pet-eggs)\n\
+ [Weapons](#weapons)\n\
+ [1H Weapons](#1h-weapons)\n\
+ [2H Weapons](#2h-weapons)\n\
+ [Armors](#armors)\n\
+ [Left Accessory](#left-accessory)\n\
+ [Right Accessory](#right-accessory)\n\
+ [Headgear](#headgear)\n\
+ [Chest](#chest)\n\
+ [Pants](#pants)\n\
+ [Shoes](#shoes)\n\
+ [Necklaces](#necklaces)\n\
+ [Rings](#rings)\n\
+ [Gloves](#gloves)\n\
+ [Shields](#shields)\n\
\n\n")
wikia.write("#### Restrictions Reference\n")
wikia.write("Special Aegis Name Markers:\n\
+ * - Rare item with drop announce.\n\
+ (dp) - This item cannot be dropped.\n\
+ (tr) - This item cannot de traded.\n\
+ (sl) - This item cannot be sold.\n\
+ (gg) - This item cannot go to storage.\n\n")
# Healing Items
wikia.write("## Healing Items\n")
wikia.write("Id|Aegis|Price|Weight|Min|Max|Delay|\n")
wikia.write("--|-----|-----|------|---|---|-----|\n")
for i in IT_HEALING:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.price +" GP|"+
i.weight +"g|"+
i.minheal +"|"+
i.maxheal +"|"+
i.delheal +"s|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
# Usable Items
wikia.write("## Usable Items\n")
wikia.write("Id|Aegis|Name|Price|Weight|\n")
wikia.write("--|-----|----|-----|------|\n")
for i in IT_USABLE:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.name +"|"+
i.price +" GP|"+
i.weight +"g|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
# Generic Items
wikia.write("## Generic Items\n")
wikia.write("Id|Aegis|Name|Price|Weight|\n")
wikia.write("--|-----|----|-----|------|\n")
for i in IT_ETC:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.name +"|"+
i.price +" GP|"+
i.weight +"g|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
# Ammo Items
wikia.write("## Ammo\n")
wikia.write("Id|Aegis|Name|Weight|Atk|Matk|\n")
wikia.write("--|-----|----|------|---|----|\n")
for i in IT_AMMO:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.name +"|"+
i.weight +"g|"+
i.atk +"|"+
i.matk +"|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
# Card Items
wikia.write("## Cards\n")
wikia.write("Id|Aegis|Name|Price|Weight|\n")
wikia.write("--|-----|----|-----|------|\n")
for i in IT_CARD:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.name +"|"+
i.price +" GP|"+
i.weight +"g|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
# Pet Egg Items
wikia.write("## Pet Eggs\n")
wikia.write("Id|Aegis|Name|Weight|\n")
wikia.write("--|-----|----|------|\n")
for i in IT_PETEGG:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.name +"|"+
i.weight +"g|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
####################################################################
wikia.write("# Weapons\n")
# 1 Hand Items
wikia.write("## 1H Weapons\n")
wikia.write("Id|Aegis|Price|Weight|Atk|Matk|Lvl|\n")
wikia.write("--|-----|-----|------|---|----|---|\n")
for i in IT_WEAPON['HAND_1']:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.price +" GP|"+
i.weight +"g|Atk: "+
i.atk +"|"+
i.matk +"|Lv: "+
i.lvl +"|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
# 2 Hand Items
wikia.write("## 2H Weapons\n")
wikia.write("Id|Aegis|Price|Weight|Atk|Matk|Lvl|Range|\n")
wikia.write("--|-----|-----|------|---|----|---|-----|\n")
for i in IT_WEAPON['HAND_2']:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.price +" GP|"+
i.weight +"g|Atk: "+
i.atk +"|"+
i.matk +"|Lv: "+
i.lvl +"|"+
i.range + "|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
####################################################################
wikia.write("# Armors\n")
ArmorWrite("Left Accessory",'EQP_ACC_L')
ArmorWrite("Right Accessory",'EQP_ACC_R')
ArmorWrite("Headgear",'EQP_HEAD_TOP')
ArmorWrite("Chest",'EQP_HEAD_MID')
ArmorWrite("Pants",'EQP_HEAD_LOW')
ArmorWrite("Shoes",'EQP_SHOES')
ArmorWrite("Necklaces",'1024')
ArmorWrite("Rings",'2048')
ArmorWrite("Gloves",'EQP_GARMENT')
ArmorWrite("Shields",'EQP_HAND_L')
# Write AegisName with restrictions
def hl(it):
buff=""
if it.rare:
buff+="*"
buff+=it.aegis
buff+=" "
if not it.drop:
buff+="[(dp)](#restrictions-reference)"
if not it.trade:
buff+="[(tr)](#restrictions-reference)"
if not it.sell:
buff+="[(sl)](#restrictions-reference)"
if not it.store:
buff+="[(gg)](#restrictions-reference)"
return buff
def ArmorWrite(name,scope):
wikia.write("## "+name+"\n")
wikia.write("Id|Aegis|Price|Weight|Def|Lvl|Script|\n")
wikia.write("--|-----|-----|------|---|---|------|\n")
for i in IT_ARMOR[scope]:
wikia.write(
i.id +"|"+
hl(i) +"|"+
i.price +" GP|"+
i.weight +"g|Def: "+
i.defs +"|Lv: "+
i.lvl +"|"+
str(i.script) + "|\n"
)
wikia.write("\n[(↑) Return to top](#items)\n\n")
showHeader()
testMobs()
newItemDB()
wikia.close()
wikib.close()
wikia.close()
showFooter()
exit(0)