Jump to content
  • 0

Problem with converter.py item_proto 40k


Agator

Question

Hello everyone I found on another community a converter for item_proto 40k, but when I open me from this problem ... 

http://it.tinypic.com/view.php?pic=15dx4le&s=8#.U6bxjkBb3XQ

this is the source of the file

import MySQLdb

item_type = {
	0: "ITEM_NONE",
	1: "ITEM_WEAPON",
	2: "ITEM_ARMOR",
	3: "ITEM_USE",
	4: "ITEM_AUTOUSE",
	5: "ITEM_MATERIAL",
	6: "ITEM_SPECIAL",
	7: "ITEM_TOOL",
	8: "ITEM_LOTTERY",
	9: "ITEM_ELK",
	10: "ITEM_METIN",
	11: "ITEM_CONTAINER",
	12: "ITEM_FISH",
	13: "ITEM_ROD",
	14: "ITEM_RESOURCE",
	15: "ITEM_CAMPFIRE",
	16: "ITEM_UNIQUE",
	17: "ITEM_SKILLBOOK",
	18: "ITEM_QUEST",
	19: "ITEM_POLYMORPH",
	20: "ITEM_TREASURE_BOX",
	21: "ITEM_TREASURE_KEY",
	22: "ITEM_SKILLFORGET",
	23: "ITEM_GIFTBOX",
	24: "ITEM_PICK",
	25: "ITEM_HAIR",
	26: "ITEM_TOTEM",
	27: "ITEM_BLEND",
	28: "ITEM_COSTUME",
	#29: "ITEM_DS",
	#30: "ITEM_SPECIAL_DS",
}

item_subtype = {
	1: {
		0: "WEAPON_SWORD",
		1: "WEAPON_DAGGER",
		2: "WEAPON_BOW",
		3: "WEAPON_TWO_HANDED",
		4: "WEAPON_BELL",
		5: "WEAPON_FAN",
		6: "WEAPON_ARROW",
		7: "WEAPON_MOUNT_SPEAR",
		8: "WEAPON_NUM_TYPES",
	},
	2: {
		0: "ARMOR_BODY",
		1: "ARMOR_HEAD",
		2: "ARMOR_SHIELD",
		3: "ARMOR_WRIST",
		4: "ARMOR_FOOTS",
		5: "ARMOR_NECK",
		6: "ARMOR_EAR",
		7: "ARMOR_NUM_TYPES",
	},
	3 : {
		0: "USE_POTION",
		1: "USE_TALISMAN",
		2: "USE_TUNING",
		3: "USE_MOVE",
		4: "USE_TREASURE_BOX",
		5: "USE_MONEYBAG",
		6: "USE_BAIT",
		7: "USE_ABILITY_UP",
		8: "USE_AFFECT",
		9: "USE_CREATE_STONE",
		10: "USE_SPECIAL",
		11: "USE_POTION_NODELAY",
		12: "USE_CLEAR",
		13: "USE_INVISIBILITY",
		14: "USE_DETACHMENT",
		15: "USE_BUCKET",
		16: "USE_POTION_CONTINUE",
		17: "USE_CLEAN_SOCKET",
		18: "USE_CHANGE_ATTRIBUTE",
		19: "USE_ADD_ATTRIBUTE",
		20: "USE_ADD_ACCESSORY_SOCKET",
		21: "USE_PUT_INTO_ACCESSORY_SOCKET",
		22: "USE_ADD_ATTRIBUTE2",
		23: "USE_RECIPE",
		24: "USE_CHANGE_ATTRIBUTE2",
		25: "USE_BIND",
		26: "USE_UNBIND",
		27: "USE_SPECIAL",
		28: "USE_SPECIAL",
		29: "AUTOUSE_BOMB",
		30: "AUTOUSE_GOLD",
	},
	5: {
		0: "MATERIAL_LEATHER",
		1: "MATERIAL_BLOOD",
		2: "MATERIAL_ROOT",
		3: "MATERIAL_NEEDLE",
		4: "MATERIAL_JEWEL",
		#5: "MATERIAL_DS_REFINE_NORMAL",
		#6: "MATERIAL_DS_REFINE_BLESSED",
		#7: "MATERIAL_DS_REFINE_HOLLY",
	},
	6: {
		0: "SPECIAL_MAP",
		1: "SPECIAL_KEY",
		2: "SPECIAL_DOC",
		3: "SPECIAL_SPIRIT",
		4: "SPECIAL_MAP",
	},
	7: {
		0 : "TOOL_FISHING_ROD",
	},
	8: {
		0: "LOTTERY_TICKET",
		1: "LOTTERY_INSTANT",
	},
	10: {
		0: "METIN_NORMAL",
		1: "METIN_GOLD",
	},
	12: {
		0: "FISH_ALIVE",
		1: "FISH_DEAD",
	},
	14: {
		0: "RESOURCE_FISHBONE",
		1: "RESOURCE_WATERSTONEPIECE",
		2: "RESOURCE_WATERSTONE",
		3: "RESOURCE_BLOOD_PEARL",
		4: "RESOURCE_BLUE_PEARL",
		5: "RESOURCE_WHITE_PEARL",
		6: "RESOURCE_BUCKET",
		7: "RESOURCE_CRYSTAL",
		8: "RESOURCE_GEM",
		9: "RESOURCE_STONE",
		10: "RESOURCE_METIN",
		11: "RESOURCE_ORE",
	},
	16: {
		0: "UNIQUE_NONE",
		1: "UNIQUE_BOOK",
		2: "UNIQUE_SPECIAL_RIDE",
		3: "UNIQUE_3",
		4: "UNIQUE_4",
		5: "UNIQUE_5",
		6: "UNIQUE_6",
		7: "UNIQUE_7",
		8: "UNIQUE_8",
		9: "UNIQUE_9",
		10: "USE_SPECIAL",
	},
	28: {
		0: "COSTUME_BODY",
		1: "COSTUME_HAIR",
	},
}

wearflag = {
	1: "WEAR_BODY",
	2: "WEAR_HEAD",
	4: "WEAR_FOOTS",
	8: "WEAR_WRIST",
	16: "WEAR_WEAPON",
	32: "WEAR_NECK",
	64: "WEAR_EAR",
	128: "WEAR_SHIELD",
	256: "WEAR_UNIQUE",
	512: "WEAR_ARROW",
	1024: "WEAR_HAIR",
	2048: "WEAR_ABILITY",
}

limittype = {
	1: "LEVEL",
	2: "STR",
	3: "DEX",
	4: "INT",
	5: "CON",
	6: "PC_BANG",
	7: "REAL_TIME",
	8: "REAL_TIME_FIRST_USE",
	9: "TIMER_BASED_ON_WEAR",
}

bonus = {
	1: "APPLY_MAX_HP",
	2: "APPLY_MAX_SP",
	3: "APPLY_CON",
	4: "APPLY_INT",
	5: "APPLY_STR",
	6: "APPLY_DEX",
	7: "APPLY_ATT_SPEED",
	8: "APPLY_MOV_SPEED",
	9: "APPLY_CAST_SPEED",
	10: "APPLY_HP_REGEN",
	11: "APPLY_SP_REGEN",
	12: "APPLY_POISON_PCT",
	13: "APPLY_STUN_PCT",
	14: "APPLY_SLOW_PCT",
	15: "APPLY_CRITICAL_PCT",
	16: "APPLY_PENETRATE_PCT",
	17: "APPLY_ATTBONUS_HUMAN",
	18: "APPLY_ATTBONUS_ANIMAL",
	19: "APPLY_ATTBONUS_ORC",
	20: "APPLY_ATTBONUS_MILGYO",
	21: "APPLY_ATTBONUS_UNDEAD",
	22: "APPLY_ATTBONUS_DEVIL",
	23: "APPLY_STEAL_HP",
	24: "APPLY_STEAL_SP",
	25: "APPLY_MANA_BURN_PCT",
	26: "APPLY_DAMAGE_SP_RECOVER",
	27: "APPLY_BLOCK",
	28: "APPLY_DODGE",
	29: "APPLY_RESIST_SWORD",
	30: "APPLY_RESIST_TWOHAND",
	31: "APPLY_RESIST_DAGGER",
	32: "APPLY_RESIST_BELL",
	33: "APPLY_RESIST_FAN",
	34: "APPLY_RESIST_BOW",
	35: "APPLY_RESIST_FIRE",
	36: "APPLY_RESIST_ELEC",
	37: "APPLY_RESIST_MAGIC",
	38: "APPLY_RESIST_WIND",
	39: "APPLY_REFLECT_MELEE",
	40: "APPLY_REFLECT_CURSE",
	41: "APPLY_POISON_REDUCE",
	42: "APPLY_KILL_SP_RECOVER",
	43: "APPLY_EXP_DOUBLE_BONUS",
	44: "APPLY_GOLD_DOUBLE_BONUS",
	45: "APPLY_ITEM_DROP_BONUS",
	46: "APPLY_POTION_BONUS",
	47: "APPLY_KILL_HP_RECOVER",
	48: "APPLY_IMMUNE_STUN",
	49: "APPLY_IMMUNE_SLOW",
	50: "APPLY_IMMUNE_FALL",
	51: "APPLY_SKILL",
	52: "APPLY_BOW_DISTANCE",
	53: "APPLY_ATT_GRADE_BONUS",
	54: "APPLY_DEF_GRADE_BONUS",
	55: "APPLY_MAGIC_ATT_GRADE",
	56: "APPLY_MAGIC_DEF_GRADE",
	57: "APPLY_CURSE_PCT",
	58: "APPLY_MAX_STAMINA",
	59: "APPLY_ATTBONUS_WARRIOR",
	60: "APPLY_ATTBONUS_ASSASSIN",
	61: "APPLY_ATTBONUS_SURA",
	62: "APPLY_ATTBONUS_SHAMAN",
	63: "APPLY_ATTBONUS_MONSTER",
	64: "APPLY_MALL_ATTBONUS",
	65: "APPLY_MALL_DEFBONUS",
	66: "APPLY_MALL_EXPBONUS",
	67: "APPLY_MALL_ITEMBONUS",
	68: "APPLY_MALL_GOLDBONUS",
	69: "APPLY_MAX_HP_PCT",
	70: "APPLY_MAX_SP_PCT",
	71: "APPLY_SKILL_DAMAGE_BONUS",
	72: "APPLY_NORMAL_HIT_DAMAGE_BONUS",
	73: "APPLY_SKILL_DEFEND_BONUS",
	74: "APPLY_NORMAL_HIT_DEFEND_BONUS",
	75: "APPLY_PC_BANG_EXP_BONUS",
	76: "APPLY_PC_BANG_DROP_BONUS",
	77: "APPLY_EXTRACT_HP_PCT",
	78: "APPLY_RESIST_WARRIOR",
	79: "APPLY_RESIST_ASSASSIN",
	80: "APPLY_RESIST_SURA",
	81: "APPLY_RESIST_SHAMAN",
	82: "APPLY_ENERGY",
	83: "APPLY_DEF_GRADE",
	84: "APPLY_COSTUME_ATTR_BONUS",
	85: "APPLY_MAGIC_ATTBONUS_PER",
	86: "APPLY_MELEE_MAGIC_ATTBONUS_PER",
	#87: "APPLY_RESIST_ICE",
	#88: "APPLY_RESIST_EARTH",
	#89: "APPLY_RESIST_DARK",
	#90: "APPLY_ANTI_CRITICAL_PCT",
	#91: "APPLY_ANTI_PENETRATE_PCT",
}

addon_type = {
	180,
	181,
	182,
	183,
	184,
	185,
	186,
	187,
	188,
	189,
	190,
	191,
	192,
	193,
	194,
	195,
	196,
	197,
	198,
	199,
	290,
	291,
	292,
	293,
	294,
	295,
	296,
	297,
	298,
	299,
	1130,
	1131,
	1132,
	1133,
	1134,
	1135,
	1136,
	1137,
	1138,
	1139,
	1170,
	1171,
	1172,
	1173,
	1174,
	1175,
	1176,
	1177,
	1178,
	1179,
	2150,
	2151,
	2152,
	2153,
	2154,
	2155,
	2156,
	2157,
	2158,
	2159,
	2170,
	2171,
	2172,
	2173,
	2174,
	2175,
	2176,
	2177,
	2178,
	2179,
	3160,
	3161,
	3162,
	3163,
	3164,
	3165,
	3166,
	3167,
	3168,
	3169,
	3210,
	3211,
	3212,
	3213,
	3214,
	3215,
	3216,
	3217,
	3218,
	3219,
	5110,
	5111,
	5112,
	5113,
	5114,
	5115,
	5116,
	5117,
	5118,
	5119,
	5120,
	5121,
	5122,
	5123,
	5124,
	5125,
	5126,
	5127,
	5128,
	5129,
	7160,
	7161,
	7162,
	7163,
	7164,
	7165,
	7166,
	7167,
	7168,
	7169,
	65159,
	350,
	351,
	352,
	353,
	354,
	355,
	356,
	357,
	358,
	359,
	360,
	361,
	362,
	363,
	364,
	365,
	366,
	367,
	368,
	369,
	1300,
	1301,
	1302,
	1303,
	1304,
	1305,
	1306,
	1307,
	1308,
	1309,
	2340,
	2341,
	2342,
	2343,
	2344,
	2345,
	2346,
	2347,
	2348,
	2349,
	3330,
	3331,
	3332,
	3333,
	3334,
	3335,
	3336,
	3337,
	3338,
	3339,
	5290,
	5291,
	5292,
	5293,
	5294,
	5295,
	5296,
	5297,
	5298,
	5299,
}

errors = ""

def get_item_type(type, vnum):
	global errors
	if type in item_type:
		return item_type[type]
	else:
		errors += "Strange type in item %srn" % vnum
		return item_type[0]

def get_item_subtype(type, subtype, vnum):
	global errors
	if type in item_subtype:
		if subtype in item_subtype[type]:
			return item_subtype[type][subtype]
	else:
		errors += "Strange subtype in item %srn" % vnum
		return "NONE"

def get_antiflag(antiflag, vnum):
	global errors
	str = ""
	if antiflag >= 131072:
		antiflag -= 131072
		if len(str) = 65536:
		antiflag -= 65536
		if len(str) = 32768:
		antiflag -= 32768
		if len(str) = 16384:
		antiflag -= 16384
		if len(str) = 8192:
		antiflag -= 8192
		if len(str) = 4096:
		antiflag -= 4096
		if len(str) = 2048:
		antiflag -= 2048
		if len(str) = 1024:
		antiflag -= 1024
		if len(str) = 512:
		antiflag -= 512
		if len(str) = 256:
		antiflag -= 256
		if len(str) = 64:
		antiflag -= 64
		if len(str) = 32:
		antiflag -= 32
		if len(str) = 16:
		antiflag -= 16
		if len(str) = 8:
		antiflag -= 8
		if len(str) = 4:
		antiflag -= 4
		if len(str) = 2:
		antiflag -= 2
		if len(str) = 1:
		antiflag -= 1
		if len(str)  0:
		return """ + str + """
	else:
		errors += "Strange antiflag in item %srn" % vnum
		return ""NONE""
	
def get_flag(flag, vnum):
	global errors
	str = ""
	if flag >= 32768:
		flag -= 32768
		if len(str) = 16384:
		flag -= 16384
		if len(str) = 8192:
		flag -= 8192
		if len(str) = 4096:
		flag -= 4096
		if len(str) = 2048:
		flag -= 2048
		if len(str) = 1024:
		flag -= 1024
		if len(str) = 512:
		flag -= 512
		if len(str) = 256:
		flag -= 256
		if len(str) = 128:
		flag -= 128
		if len(str) = 64:
		flag -= 64
		if len(str) = 32:
		flag -= 32
		if len(str) = 16:
		flag -= 16
		if len(str) = 8:
		flag -= 8
		if len(str) = 4:
		flag -= 4
		if len(str) = 2:
		flag -= 2
		if len(str) = 1:
		flag -= 1
		if len(str)  0:
		return """ + str + """
	else:
		errors += "Strange flag in item %srn" % vnum
		return ""NONE""

def get_wearflag(wear, vnum):
	global errors
	if wear in wearflag:
		return """ + wearflag[wear] + """
	else:
		errors += "Strange wearflag in item %srn" % vnum
		return ""NONE""
		
def get_immuneflag(immune):
		return ""NONE""
		
def get_limittype(limit):
	if limit in limittype:
		return """ + limittype[limit] + """
	else:
		return ""LIMIT_NONE""
		
def get_apply(apply):
	if apply in bonus:
		return """ + bonus[apply] + """
	else:
		return ""APPLY_NONE""

def socket(sockett):
	if sockett == 127:
		return 0
	else:
		return sockett


print "Connecting to database proto..."
db = MySQLdb.connect(host="MYIP", user="root", passwd="PASS", db="player")
cur = db.cursor()
print "Connected."
cur.execute("select * from item_proto")
rows = cur.fetchall()
out_file_itemproto = open("item_proto.txt", "w")
out_file_itemnames = open("item_names.txt", "w")
print "Converting item_proto..."
for row in rows:
	item_proto_line = "%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%s" % (row[0], """ + row[1] + """, """  + get_item_type(row[3], row[0]) + """ , """  + get_item_subtype(row[3], row[4], row[0]) + """, row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
	item_names_line = "%st%s" % (row[0], row[2])
	out_file_itemproto.write(item_proto_line + "rn")
	out_file_itemnames.write(item_names_line + "rn")
out_file_itemproto.close()
print "Item_proto converted!"
"""if len(errors) != 0:
	print "Errors during conversion:"
	print errors"""

Sorry fo my english...

Link to comment
  • Answers 0
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.