diff options
-rwxr-xr-x | wiki/wikigen.py | 965 |
1 files changed, 263 insertions, 702 deletions
diff --git a/wiki/wikigen.py b/wiki/wikigen.py index b4ccf05..340dfef 100755 --- a/wiki/wikigen.py +++ b/wiki/wikigen.py @@ -12,81 +12,30 @@ from xml.dom import minidom 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': [], # ? + 'EQP_ACC_R': [], # ? + 'EQP_HEAD_MID': [], # CHEST + 'EQP_SHOES': [], # FEET + 'EQP_GARMENT': [], # GLOVES + 'EQP_HEAD_LOW':[], # PANTS + '2048': [], # RINGS (should be EQP_COSTUME_HEAD_MID instead of number) + 'EQP_HEAD_TOP':[], # HATS/HELMETS + 'EQP_HAND_L': [], # SHIELDS + 'EQP_HAND_R':[]} # WEAPONS + + -iconsDir = "graphics/items/" -spritesDir = "graphics/sprites/" -particlesDir = "graphics/particles/" -sfxDir = "sfx/" -musicDir = "music/" -mapsDir = "maps/" -spriteErrorFile = "error.xml" -levelUpEffectFile = "levelup.particle.xml" -portalEffectFile = "warparea.particle.xml" -minimapsDir = "graphics/minimaps/" -wallpapersDir = "graphics/images/" -wallpaperFile = "login_wallpaper.png" - -errors = 0 -warnings = 0 -errDict = set() -safeDye = False -borderSize = 20 -colorsList = set() -showAll = False -silent = False -herc = False - -testBadCollisions = False -# number of tiles difference. after this amount tiles can be counted as incorrect -tileNumDiff = 3 -# max number of incorrect tiles. If more then tile not counted as error -maxNumErrTiles = 5 - -class Tileset: - None - -class Layer: - None - -def printErr(err): - errDict.add(err) - #print err - -def showFileErrorById(id, rootDir, fileDir): - rootDir = rootDir - fileDir = fileDir - #print "error: id=" + id + ", file not found: " + fileDir + " (" + rootDir + fileDir + ")" - -def showFileWarningById(id, rootDir, fileDir): - rootDir = rootDir - fileDir = fileDir - #print "warn: id=" + id + ", file not found: " + fileDir + " (" + rootDir + fileDir + ")" - -def showError(id, text): - text = text - #print "error: id=" + id + " " + text - -def showWarning(id, text): - text = text - #print "warn: id=" + id + " " + text - -def showMsg(id, text, src, iserr): - pass - -def showMsgSprite(file, text, iserr): - pass - -def showMsgFile(file, text, iserr): - pass - -def showFileMsgById(id, rootDir, fileDir, iserr): - global errors, warnings - if iserr == True: - showFileErrorById(id, rootDir, fileDir) - errors = errors + 1 - else: - showFileWarningById(id, rootDir, fileDir) - warnings = warnings + 1 def printSeparator(): print("--------------------------------------------------------------------------------") @@ -103,473 +52,11 @@ def showFooter(): #printSeparator() print("Done.") -def checkFilePermission(fullName): - global warnings - if os.access(fullName, os.X_OK): - #print "warn: execute flag on file: " + fullName - warnings = warnings + 1 - - -def loadPaths(): - pass - -def splitImage(image): - try: - idx = image.find("|") - if idx > 0: - imagecolor = image[idx + 1:] - image = image[0:idx] - else: - imagecolor = "" - except: - image = "" - imagecolor = "" - return [image, imagecolor] - -def testDye(id, color, text, src, iserr): - pass - - -def testDyeInternal(id, col, text, src, iserr): - return True - - -def testDyeColors(id, color, text, src, iserr): - return 4 - -def testDyeChannel(file, color, text, iserr): - return 1 - - -def testSprites(id, node, checkGender, isNormalDye, isMust, checkAction, iserr): - pass - -def testSprite(id, file, variant, isNormalDye, checkAction, iserr): - pass - -def powerOfTwo(num): - val = 1 - while val < num: - val = val * 2 - return val - -def testSpriteFile(id, fullPath, file, fileLoc, dnum, variant, checkAction, iserr): - pass - -def testSpriteAction(file, name, action, numframes, iserr): - pass -def testImageFile(file, fullPath, sz, src, iserr): - pass -def testSound(file, sfxDir, msg): - pass -def testItems(fileName, imgDir): - global warnings, errors, safeDye - #print "Checking " + fileName - wikia.write("# Items\n\ -+ [Usable Items](#usable-items)\n\ -+ [Generic Items](#generic-items)\n\ -+ [1H Weapons](#1h-weapons)\n\ -+ [2H Weapons and Ammo](#2h-weapons-and-ammo)\n\ -+ [Trinkets](#trinkets)\n\ -+ [Headgear](#headgear)\n\ -+ [Armors](#armors)\n\ -+ [Pants](#pants)\n\ -+ [Boots](#boots)\n\ -\n") - - wk_usb=[] - wk_generic=[] - wk_neck=[] - wk_1h=[] - wk_2h=[] -# Shield, gloves, wings, pets, cards and such are still not handled. - #wk_shd=[] - - wk_arm=[] - wk_pant=[] - wk_shoe=[] - wk_helm=[] - - try: - dom = minidom.parse(parentDir + "/" + fileName) - except Exception as err: - #print "error: " + fileName + ": corrupted" - #print err - errors = errors + 1 - return - idset = set() - #oldId = None - for node in dom.documentElement.childNodes: - if node.nodeName == "include": - try: - name = node.attributes["name"].value - if name == "": - errors = errors + 1 - #print "error: " + fileName + ": Empty include name"; - testItems(name, imgDir) - except: - errors = errors + 1 - #print "error: " + fileName + ": Broken include tag"; - continue - if node.nodeName != "item": - continue - - if node.parentNode != dom.documentElement: - continue - - try: - id = node.attributes["id"].value - except: - errors = errors + 1 - continue - #oldId = id - if id in idset: - #print "error: " + fileName + ": duplicated id=" + id - errors = errors + 1 - else: - idset.add(id) - - idI = int(id) - - try: - colors = node.attributes["colors"].value - except: - colors = None - - try: - type = node.attributes["type"].value - except: - type = "" - #print "warn: " + fileName + ": no type attribute for id=" + id - warnings = warnings + 1 - try: - image = node.attributes["image"].value - image0 = image - img = splitImage(image) - image = img[0] - imagecolor = img[1] - except: - image = "" - image0 = "" - imagecolor = "" - - try: - floor = node.attributes["floor"].value - floor0 = floor - flr = splitImage(floor) - floor = flr[0] - floorcolor = flr[1] - except: - floor = None - floor0 = None - floorcolor = None - - try: - description = node.attributes["description"].value - except: - description = "" - - #try: - # missile = node.attributes["missile-particle"].value - #except: - # missile = "" - - try: - drawBefore = node.attributes["drawBefore"].value - except: - drawBefore = "" - - try: - drawAfter = node.attributes["drawAfter"].value - except: - drawAfter = "" - -# try: -# drawPriority = int(node.attributes["drawPriority"].value) -# except: -# drawPriority = 0 - - if type == "hairsprite": - if idI >= 0: - #print "error: " + fileName + ": hairsprite with id=" + id - errors = errors + 1 - elif idI < -100: - #print "error: " + fileName + ": hairsprite override player sprites" - errors = errors + 1 - - safeDye = True - testSprites(id, node, True, True, True, "", True) - safeDye = False - - elif type == "racesprite": - if idI >= 0: - #print "error: " + fileName + ": racesprite with id=" + id - errors = errors + 1 - elif idI > -100: - #print "error: " + fileName + ": racesprite override player hair" - errors = errors + 1 - elif type == "usable" or type == "unusable" or type == "generic" \ - or type == "equip-necklace" or type == "equip-torso" or type == "equip-feet" \ - or type == "equip-arms" or type == "equip-legs" or type == "equip-head" \ - or type == "equip-shield" or type == "equip-1hand" or type == "equip-2hand" \ - or type == "equip-charm" or type == "equip-ammo" or type == "equip-neck" \ - or type == "equip-ring" or type == "card": - if image == "": - #print "error: " + fileName + ": missing image attribute on id=" + id - errors = errors + 1 - continue - elif len(imagecolor) > 0: - if colors is None: - testDye(id, imagecolor, "image=" + image0, fileName, True) - else: - testDyeChannel(id, imagecolor, "image=" + image0, True) - if colors not in colorsList: - #print "error: " + fileName + ": colors value " + colors + " not found in itemcolors.xml" - errors = errors + 1 - - if floorcolor != None and len(floorcolor) > 0: - if colors is None: - testDye(id, floorcolor, "floor=" + floor0, fileName, True) - else: - testDyeChannel(id, imagecolor, "floor=" + floor0, True); - if colors not in colorsList: - #print "error: " + fileName + ": colors value " + colors + " not found in itemcolors.xml" - errors = errors + 1 - - if description == "": - #print "warn: " + fileName + ": missing description attribute on id=" + id - warnings = warnings + 1 - elif description == ".": - #print "warn: " + fileName + ": broken description attribute on id=" + id - warnings = warnings + 1 - - - try: - floorSprite = node.getElementsByTagName("floor")[0] - except: - floorSprite = None - - if floorSprite != None: - if floor != None: - errors = errors + 1 - - testSprites(id, floorSprite, False, colors is None, True, "", err) - - fullPath = os.path.abspath(parentDir + "/" + imgDir + image) - if not os.path.isfile(fullPath) or os.path.exists(fullPath) == False: - showFileErrorById (id, imgDir, image) - errors = errors + 1 - else: - testImageFile(imgDir + image, fullPath, 32, "", True) - - if floor != None: - fullPath = os.path.abspath(parentDir + "/" + imgDir + floor) - if not os.path.isfile(fullPath) or os.path.exists(fullPath) == False: - showFileErrorById (id, imgDir, floor) - errors = errors + 1 - else: - testImageFile(imgDir + floor, fullPath, 0, "", True) - - testItemReplace(id, node, "replace") - if drawBefore != "": - checkSpriteName(id, drawBefore) - if drawAfter != "": - checkSpriteName(id, drawAfter) - - try: - attackaction = node.attributes["attack-action"].value - except: - attackaction = "" - - testSprites(id, node, True, colors is None, False, attackaction, True) - - if type != "usable" and type != "unusable" and type != "generic" \ - and type != "equip-necklace" and type != "equip-1hand" \ - and type != "equip-2hand" and type != "equip-ammo" \ - and type != "equip-charm" and type != "equip-neck": - err = type != "equip-shield" - testSprites(id, node, True, colors is None, True, "", err) - - if type == "usable": - try: - wk_usb.append([node.attributes["id"].value,node.attributes["name"].value,node.attributes["effect"].value]) - except: - wk_usb.append([node.attributes["id"].value,node.attributes["name"].value,"UNKNOWN"]) - elif type == "unusable" or type == "generic": - try: - wk_generic.append([node.attributes["id"].value,node.attributes["name"].value]) - except: - wk_generic.append([node.attributes["id"].value,"SYSTEM ERROR"]) - elif type == "equip-1hand": - try: - wk_1h.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["attack"].value, "Lv "+node.attributes["level"].value]) - except: - wk_1h.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["attack"].value,"-"]) - elif type == "equip-2hand": - try: - wk_2h.append([node.attributes["id"].value,node.attributes["attack-range"].value,node.attributes["name"].value, node.attributes["attack"].value, "Lv "+node.attributes["level"].value]) - except: - wk_2h.append([node.attributes["id"].value,"?",node.attributes["name"].value, node.attributes["attack"].value,"-"]) - elif type == "equip-ammo": - try: - wk_2h.append([node.attributes["id"].value,"-".value,node.attributes["name"].value, node.attributes["attack"].value, "Lv "+node.attributes["level"].value]) - except: - wk_2h.append([node.attributes["id"].value,"-",node.attributes["name"].value, node.attributes["attack"].value,"-"]) - if type == "equip-necklace" or type == "equip-neck": - try: - wk_neck.append([node.attributes["id"].value,"NECK",node.attributes["name"].value,node.attributes["effect"].value]) - except: - wk_neck.append([node.attributes["id"].value,"NECK",node.attributes["name"].value,"UNKNOWN"]) - if type == "equip-charm": - try: - wk_neck.append([node.attributes["id"].value,"RING",node.attributes["name"].value,node.attributes["effect"].value]) - except: - wk_neck.append([node.attributes["id"].value,"RING",node.attributes["name"].value,"UNKNOWN"]) - elif type == "equip-head": - try: # why not head? - wk_helm.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value, "Lv "+node.attributes["level"].value]) - except: - wk_helm.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value,"-"]) - elif type == "equip-torso": - try: - wk_arm.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value, "Lv "+node.attributes["level"].value]) - except: - wk_arm.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value,"-"]) - elif type == "equip-legs": - try: - wk_pant.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value, "Lv "+node.attributes["level"].value]) - except: - wk_pant.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value,"-"]) - elif type == "equip-feet": - try: - wk_shoe.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value, "Lv "+node.attributes["level"].value]) - except: - wk_shoe.append([node.attributes["id"].value,node.attributes["name"].value, node.attributes["defense"].value,"-"]) - - elif type == "other": - None - elif type != "": - #print "warn: " + fileName + ": unknown type '" + type + "' for id=" + id - warnings = warnings + 1 - - - print("Generating Item Wiki...") - ################################################### USABLE - wikia.write("## Usable Items\n") - wikia.write("| ID | ITEM | EFFECT |\n\ -| -- | -------------- | ------ |\n") - # Show image? - for i in wk_usb: - wikia.write(i[0] + "|" + i[1] + "|" + i[2] +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### GENERIC - wikia.write("## Generic Items\n") - wikia.write("| ID | ITEM |\n\ -| -- | -------------- |\n") - # Show image? - for i in wk_generic: - wikia.write(i[0] + "|" + i[1] + "|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### 1 Hand Weapons - wikia.write("## 1H Weapons\n") - wikia.write("| ID | ITEM | ATK | LVL\n\ -| -- | -------------- | --- | ---|\n") - for i in sorted(wk_1h, key=lambda x: x[2], reverse=True): - try: - wikia.write(i[0] + - "|" + i[1] + - "|" + i[2] + - "|" + i[3] +"|\n") - except: - wikia.write(i[0] + - "|" + i[1] + - "|" + "INVALID" + - "|" + "INVALID" +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### 2 Hand Weapons and Ammo - wikia.write("## 2H Weapons and Ammo\n") - wikia.write("| ID | Range | ITEM | ATK | LVL\n\ -| -- | -- | ---------- | --- | ---|\n") - for i in sorted(wk_2h, key=lambda x: x[1], reverse=True): - try: - wikia.write(i[0] + - "|" + i[1] + - "|" + i[2] + - "|" + i[3] + - "|" + i[4] +"|\n") - except: - wikia.write(i[0] + - "|" + "INVALID" + - "|" + "INVALID" + - "|" + "INVALID" + - "|" + "INVALID" +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### 2 Hand Weapons and Ammo - wikia.write("## Trinkets\n") - wikia.write("| ID | Slot | ITEM | EFFECT\n\ -| -- | -- | ---------- | --- |\n") - for i in sorted(wk_neck, key=lambda x: x[1], reverse=True): - try: - wikia.write(i[0] + "|" + i[1] + "|" + i[2] +"|" + i[3] +"|\n") - except: - wikia.write(i[0] + "|" + i[1] + "|" + "INVALID NAME! NON ASCII CHAR FOUND." +"|" + "INVALID EFFECT! NON ASCII CHAR FOUND." +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### Helmets - wikia.write("## Headgear\n") - wikia.write("| ID | ITEM | DEF | LVL\n\ -| -- | -------------- | --- | ---|\n") - for i in sorted(wk_helm, key=lambda x: x[2], reverse=True): - wikia.write(i[0] + "|" + i[1] + "|" + i[2] +"|" + i[3] +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### Armors - wikia.write("## Armors\n") - wikia.write("| ID | ITEM | DEF | LVL\n\ -| -- | -------------- | --- | ---|\n") - for i in sorted(wk_arm, key=lambda xy: xy[2], reverse=True): - try: - wikia.write(i[0] + "|" + i[1] + "|" + i[2] +"|" + i[3] +"|\n") - except: - wikia.write(i[0] + "|" + "INVALID" + "|" + "INVALID" +"|" + "INVALID" +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### Pants - wikia.write("## Pants\n") - wikia.write("| ID | ITEM | DEF | LVL\n\ -| -- | -------------- | --- | ---|\n") - for i in sorted(wk_pant, key=lambda xz: xz[2], reverse=True): - wikia.write(i[0] + "|" + i[1] + "|" + i[2] +"|" + i[3] +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - - ################################################### Boots - wikia.write("## Boots\n") - wikia.write("| ID | ITEM | DEF | LVL\n\ -| -- | -------------- | --- | ---|\n") - for i in sorted(wk_shoe, key=lambda x: x[2], reverse=True): - wikia.write(i[0] + "|" + i[1] + "|" + i[2] +"|" + i[3] +"|\n") - wikia.write('[Back to Top](#items)\n') - wikia.write('\n') - -# Shield, gloves, wings, pets, cards and such are still not handled. - def writeMob(wikib, tmb): wikib.write("|"+ tmb[0]+"|"+ @@ -630,178 +117,252 @@ def testMobs(): def stp(x): return x.replace('\n', '').replace('|', '').replace('(int, defaults to ', '').replace(')', '').replace('basic experience', '').replace('"','').replace(" ","").replace('(string', '').replace('Name: ','').replace('AttackDelay', 'ms') -def testItemReplace(id, rootNode, name): - global warnings, errors - for node in rootNode.getElementsByTagName(name): - if node.parentNode != rootNode: - continue - try: - sprite = node.attributes["sprite"].value - except: - if len(node.attributes) != 0: - #print "error: reading replace sprite name, id=" + str(id) - errors = errors + 1 - continue - checkSpriteName(id, sprite) - for itemNode in node.getElementsByTagName("item"): - if itemNode.parentNode != node: - continue - #TODO here need check "from" and "to" for correct item id - - -def checkSpriteName(id, name): - global warnings, errors - if name != "race" and name != "type" and name != "shoes" and name != "boot" and \ - name != "boots" and name != "bottomclothes" \ - and name != "bottom" and name != "pants" and name != "topclothes" and \ - name != "top" and name != "torso" and name != "body" and name != "misc1" \ - and name != "misc2" and name != "scarf" and name != "scarfs" and \ - name != "hair" and name != "hat" and name != "hats" and name != "wings" \ - and name != "glove" and name != "gloves" and name != "weapon" and \ - name != "weapons" and name != "shield" and name != "shields" and \ - name != "amulet" and name != "amulets" and name != "ring" and name != "rings": - #print "error: unknown sprite name " + name + ", id=" + str(id) - errors = errors + 1 - - - - -def splitBytes(num): - i1 = int(num % 256) - i2 = int(((num % 65536) - i1) / 256) - i3 = int(((num % 16777216) - i2 - i1) / 65536) - i4 = int(((num % 4294967296) - i3 - i2 - i1) / 16777216) - return (i1, i2, i3, i4) - - -def testDirExists(path): - global errors - fullName = parentDir + "/" + path - if not os.path.exists(fullName): - #print "error: path '" + path + "' not exists." - errors = errors + 1 - elif not os.path.isdir(fullName): - #print "error: path '" + path + "' is incorrect directory." - errors = errors + 1 - -def testDefaultFiles(): - pass - -def testMinimapsDir(): - pass - -def testImagesDir(imagesDir, sz): - pass - -def testSpritesDir(dir): - pass - -def testParticlesDir(dir): - pass - -def testSoundsDir(dir, sfxDir): - return - -def testItemColors(fileName): - global warnings, errors, safeDye, colorLists - #print "Checking itemcolors.xml" - try: - dom = minidom.parse(parentDir + "/" + fileName) - except: - return - - for node in dom.getElementsByTagName("list"): - if node.parentNode != dom.documentElement: - continue - - try: - name = node.attributes["name"].value - except: - #print "error: colors list dont have name" - errors = errors + 1 - continue - if name in colorsList: - #print "error: duplicate color list: " + name - errors = errors + 1 - continue - colorsList.add(name) - colors = set() - names = set() - for colorNode in node.getElementsByTagName("color"): - if colorNode.parentNode != node: - continue - try: - id = colorNode.attributes["id"].value - except: - #print "error: getting id in list: " + name - errors = errors + 1 - continue - try: - colorName = colorNode.attributes["name"].value - except: - #print "error: getting name in list: " + name - errors = errors + 1 - continue - try: - colorDye = colorNode.attributes["value"].value - except: - #print "error: getting color in list: " + name - errors = errors + 1 - if id in colors: - #print "error: color with id " + str(id) + " already in list: " + name - errors = errors + 1 - else: - colors.add(id) - if colorName in names: - #print "error: color with name \"" + colorName + "\" already in list: " + name - errors = errors + 1 - else: - names.add(colorName) - testDyeColors(id, colorDye, colorDye, name, True) - -def haveXml(dir): - if not os.path.isdir(dir) or not os.path.exists(dir): - return False - for file in os.listdir(dir): - #if filt.search(file): - return True - return False - - -def detectClientData(dirs): - global parentDir - parentDir="../../client-data" - return - for dir in dirs: - if haveXml(dir): - #print "Detected client data directory in: " + dir - parentDir = dir - return True - - #print "Cant detect client data directory" - exit(1) - - -if len(sys.argv) == 2: - if sys.argv[1] == "all": - showAll = True - elif sys.argv[1] == "silent": - silent = True - elif sys.argv[1] == "herc": - silent = True - herc = True + + + + + + + + + +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" 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 '2048' in it.loc: + IT_ARMOR['2048'].append(it) + else: + IT_ARMOR['MISC'].append(it) + +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 " Name:" in a: + x.name=sti(a) + elif " AegisName:" in a: + x.aegis=sti(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('(int, defaults to ', '').replace(')', '').replace('Id: ', '').replace('"','').replace(" ","").replace('(string', '').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 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\ ++ [1H Weapons](#1h-weapons)\n\ ++ [2H Weapons](#2h-weapons)\n\ ++ [Armor](#armor)\n\ + + [Error](#error)\n\ + + [Bonus L](#bonus-l)\n\ + + [Bonus R](#bonus-r)\n\ + + [Headgear](#headgear)\n\ + + [Chest](#chest)\n\ + + [Pants](#pants)\n\ + + [Shoes](#shoes)\n\ + + [Rings](#rings)\n\ + + [Gloves](#gloves)\n\ + + [Shields](#shields)\n\ + + [Right Hand](#right-hand)\n\ +\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 +"|"+ + i.aegis +"|"+ + i.price +"|"+ + i.weight +"|"+ + i.minheal +"|"+ + i.maxheal +"|"+ + i.delheal +"|\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 +"|"+ + i.aegis +"|"+ + i.name +"|"+ + i.price +"|"+ + i.weight +"|\n" + ) + + """ + IT_AMMO=[] + IT_CARD=[] + IT_PETEGG=[] + IT_WEAPON={ 'HAND_1' 1h-weapons + 'HAND_2' 2h-weapons + IT_ARMOR={ 'MISC' error + 'EQP_ACC_L': bonus-l + 'EQP_ACC_R': bonus-r + 'EQP_HEAD_TOP': + 'EQP_HEAD_MID': + 'EQP_HEAD_LOW': + 'EQP_SHOES': + '2048': + 'EQP_GARMENT': + 'EQP_HAND_L': + 'EQP_HAND_R': + """ + + # 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 +"|"+ + i.aegis +"|"+ + i.name +"|"+ + i.price +"|"+ + i.weight +"|\n" + ) + showHeader() -#print "Detecting clientdata dir" -detectClientData([".", "..", "../../client-data", "../../clientdata"]) -#print "Checking xml file syntax" -#loadPaths() -#testItemColors("/itemcolors.xml") -testItems("/items.xml", iconsDir) testMobs() +newItemDB() wikia.close() wikib.close() +wikia.close() + showFooter() exit(0) |