From The Mana World
m (Username wiki links)
(Added images of the new monsters (as wikilinks))
Line 29: Line 29:
'Snake' : "http://img219.echo.cx/img219/4030/monster82xf.gif",
'Snake' : "http://img219.echo.cx/img219/4030/monster82xf.gif",
'Fire_Goblin': "http://img221.echo.cx/img221/5295/monster91hy.gif",
'Fire_Goblin': "http://img221.echo.cx/img221/5295/monster91hy.gif",
'Spider': "http://img305.imageshack.us/img305/8467/spider4xg.gif"
'Spider': "http://img305.imageshack.us/img305/8467/spider4xg.gif",
'RudolphSlime': "[[Image:Rudolphslime.png]]",
'SantaSlime': "[[Image:Santaslime.png]]",
'SleepFlower': "[[Image:Sleepflower.png]]",
'EvilMushroom': "[[Image:Evilmushroom.png]]",
'Bat': "[[Image:Bat.png]]"
}
}



Revision as of 13:12, 9 January 2006

Strength of Red Scorpion

Wasnt the RED scorpion supposed to be a miniboss? that HP seems kinda low for one :o --Bear

Cool, I was thinking about bosses too. I believe that Red Guy is like a boss. There are too many snakes and spiders, a DRAGON should be a good idea for a boss. But ONLY ONE DRAGON, please. --BrightCiro (Ciro Leonardo, the char)

Python program dbtowiki

This is a program to autogenerate a monster page in wikicode from eAthena configuration files.

dbtowiki without any arguments will use item_db.txt and mob_db.txt in the current directory to write a monster list in wikicode to stdout. To specify custom files, call: dbtowiki <mob_db> <item_db>

#!/usr/bin/python
#Licensed under GNU General Public License
import sys, os;

imageurls = {
'Maggot': "http://img74.echo.cx/img74/4223/maggot2qf.gif",
'Scorpion': "http://img72.echo.cx/img72/3383/scorpion3wa.gif",
'RedScorpion': "http://img72.echo.cx/img72/8718/redscorpion8yz.gif",
'GreenSlime': "http://img275.echo.cx/img275/4739/greenslime8up.gif",
'GiantMaggot': "http://img264.echo.cx/img264/7048/giantmaggot6bi.gif",
'Yellow_slime': "http://img221.echo.cx/img221/5411/yellowslime6pa.gif",
'Red_slime': "http://img221.echo.cx/img221/8781/redslime1hj.gif",
'BlackScorpion': "http://img275.echo.cx/img275/7117/blackscorpion0lm.gif",
'Snake' : "http://img219.echo.cx/img219/4030/monster82xf.gif",
'Fire_Goblin': "http://img221.echo.cx/img221/5295/monster91hy.gif",
'Spider': "http://img305.imageshack.us/img305/8467/spider4xg.gif",
'RudolphSlime': "[[Image:Rudolphslime.png]]",
'SantaSlime': "[[Image:Santaslime.png]]",
'SleepFlower': "[[Image:Sleepflower.png]]",
'EvilMushroom': "[[Image:Evilmushroom.png]]",
'Bat': "[[Image:Bat.png]]"
}

class whatever: pass

log = []

def saveint(string):
    a = 0
    try:
        a = int(string)
    except:
        a = 0
    return a
        

def parsemonsters(file):
    objects = []
    for line in file:
        s = line[0:line.find('//')].strip()
        if s:
            values = s.split(',')
            if (len(values) != 54):
                log.append("mob_db: Warning, monster-line with ID %s has %d values instead of 54" % (values[0], len(values)))
                while (len(values) < 54):
                    values.append('')
                while (len(values) > 54):
                    values.pop()
            o = whatever()
            o.id = saveint(values[0])
            o.name = values[1]
            o.jname = values[2]
            o.lvl = saveint(values[3])
            o.hp = saveint(values[4])
            o.sp = saveint(values[5])
            o.exp = saveint(values[6])
            o.expj = saveint(values[7])
            o.range1 = saveint(values[8])
            o.atk1 = saveint(values[9])
            o.atk2 = saveint(values[10])
            o.defense = saveint(values[11])
            o.mdefense = saveint(values[12])
            o.strength = saveint(values[13])
            o.agility = saveint(values[14])
            o.vitality = saveint(values[15])
            o.intelligence = saveint(values[16])
            o.dexterity = saveint(values[17])
            o.luck = saveint(values[18])
            o.range2 = saveint(values[19])
            o.range3 = saveint(values[20])
            o.scale = saveint(values[21])
            o.race = saveint(values[22])
            o.element = saveint(values[23])
            o.mode = saveint(values[24])
            o.speed = saveint(values[25])
            o.adelay = saveint(values[26])
            o.amotion = saveint(values[27])
            o.dmotion = saveint(values[28])
            o.drop = []
            for i in range(8):
                o.drop.append(whatever())
            o.drop[0].id = saveint(values[29])
            o.drop[0].per = saveint(values[30])
            o.drop[1].id = saveint(values[31])
            o.drop[1].per = saveint(values[32])
            o.drop[2].id = saveint(values[33])
            o.drop[2].per = saveint(values[34])
            o.drop[3].id = saveint(values[35])
            o.drop[3].per = saveint(values[36])
            o.drop[4].id = saveint(values[37])
            o.drop[4].per = saveint(values[38])
            o.drop[5].id = saveint(values[39])
            o.drop[5].per = saveint(values[40])
            o.drop[6].id = saveint(values[41])
            o.drop[6].per = saveint(values[42])
            o.drop[7].id = saveint(values[43])
            o.drop[7].per = saveint(values[44])
            o.item1 = saveint(values[45])
            o.item2 = saveint(values[46])
            o.mexp = saveint(values[47])
            o.expper = saveint(values[48])
            o.mvp = []
            for i in range(3):
                o.mvp.append(whatever())
            o.mvp[0].id = saveint(values[49])
            o.mvp[0].per = saveint(values[50])
            o.mvp[1].id = saveint(values[50])
            o.mvp[1].per = saveint(values[51])
            o.mvp[2].id = saveint(values[52])
            o.mvp[2].per = saveint(values[53])

            objects.append(o)

    return objects

def addimageurls(monsters):
    global imageurls
    for m in monsters:
        if imageurls.has_key(m.name):
            m.imgurl = imageurls[m.name]
        else:
            m.imgurl = ''

def adddropnames(monsters,dropnames):
    for m in monsters:
        for d in m.drop:
            if dropnames.has_key(d.id):
                d.name = dropnames[d.id]
            else:
                d.name = ''
    


def parseitemnames(file):
    global log
    dic = {}
    for line in file:
        s = line[0:line.find('//')].strip()
        if s:
            values = s.split(',')
            if (len(values) < 3):
                if len(values) > 0: log.append("mob_db: Warning, item-line with ID %s doesnt even have 3 values. Skipped." % (values[0], len(values)))
            else:
                id = int(values[0])
                dic[id] = values[2];
    return dic


def printlog():
    global log
    if len(log) > 0:
        sys.stdout.write('\n---------------------------------------\n')
    for line in log:
        sys.stdout.write(line+'\n')

def getdropstring(monster):
    i = 0
    output = ""
    monster.drop.sort(lambda x,y: y.per-x.per)
    for d in monster.drop:
        if d.name: 
            if (i != 0):
                output += '<br>'
            s = ""
            if d.per >= 1000:
                s = "%d" % (d.per/100)
            elif d.per >= 100:
                if (d.per % 100) != 0:
                    s = "%1.1f" % (d.per/100.0)
                else:
                    s = "%d" % (d.per/100)
            else:
                if (d.per % 1000) != 0:
                    s = "%.2f" % (d.per/100.0)
                else:
                    s = "%.1f" % (d.per/100.0)
            output += ("%s %s%%" % (d.name.replace('_',' '), s))
            i = i + 1
    return output

def printmonsters(monsters):
    sys.stdout.write('{| border="1" cellspacing="0" cellpadding="5" width="100%" align="center"\n')
    sys.stdout.write('! style="background:#efdead;" | Image\n')
    sys.stdout.write('! style="background:#efdead;" | Name\n')
    sys.stdout.write('! style="background:#efdead;" | ID\n')
    sys.stdout.write('! style="background:#efdead;" | HP\n')
    sys.stdout.write('! style="background:#efdead;" | Attack\n')
    sys.stdout.write('! style="background:#efdead;" | Exp. Points\n')
    sys.stdout.write('! style="background:#efdead;" | Dropped Items\n')
    for m in monsters:
        sys.stdout.write('|-\n')
        sys.stdout.write('| align="center" | %s\n' % m.imgurl)
        sys.stdout.write('| %s\n' % m.jname.replace('_',' ') )
        sys.stdout.write('| align="center" | %d\n' % m.id)
        sys.stdout.write('| align="center" | %d\n' % m.hp)
        if m.atk1 < m.atk2:
            sys.stdout.write('| align="center" | %d-%d\n' % (m.atk1, m.atk2))
        elif m.atk1 > m.atk2:
            sys.stdout.write('| align="center" | %d-%d\n' % (m.atk2, m.atk1))
        else:
            sys.stdout.write('| align="center" | %d\n' % m.atk1)
            
        sys.stdout.write('| align="center" | %d\n' % m.exp)
        sys.stdout.write('| %s' % getdropstring(m))

        sys.stdout.write('\n')
    sys.stdout.write('|}')
            

    

#MAIN
try:
    if (len(sys.argv) == 1):
        mob_db = "mob_db.txt"
        item_db = "item_db.txt"
    elif (len(sys.argv) == 3):
        mob_db = sys.argv[1]
        item_db = sys.argv[2]
    else: 
        mob_db = ''
        item_db = ''
        sys.stdout.write("Wrong number of arguments\n")

    if (mob_db and item_db) :
        if (not os.path.isfile(mob_db)):
            sys.stdout.write("File does not exist: %s\n" % mob_db)
            mob_db = ''
        if (not os.path.isfile(item_db)):
            sys.stdout.write("File does not exist: %s\n" % item_db)
            item_db = ''
    
    if not (mob_db and item_db):
        sys.stdout.write("\nUSAGE:\n")
        sys.stdout.write("dbtowiki without any arguments will use item_db.txt and mob_db.txt in the current directory.\n")
        sys.stdout.write("to specify custom files, call: dbtowiki <mob_db> <item_db>\n")
        exit(-1);
    else:
        log.append("Monster-list [mob_db] = %s" % mob_db)
        log.append("Item-list [item_db] = %s" % item_db)
        f = open(mob_db)
        monsters = parsemonsters(f);
        f = open(item_db)
        itemnames = parseitemnames(f);

        addimageurls(monsters)
        adddropnames(monsters,itemnames)
        monsters.sort(lambda x, y: x.hp*(x.atk1+x.atk2) - y.hp*(y.atk1+y.atk2) )

        printmonsters(monsters)
        sys.stdout.write("\n\n")

finally:
    printlog()