Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randrange as rr
- from time import time, gmtime, strftime
- import argparse
- uinfo = []
- chids = []
- citms = []
- def write():
- q_0 = 'mysqli_query($conn,"INSERT INTO `df_characters` (`id`,`userid`,`name`,`level`,`dragon_amulet`,`race`,`born`,`gender`,`HomeTownID`,`HasHouse`,`hairid`,`colorhair`,`colorskin`,`colorbase`,`colortrim`,`classid`,`BaseClassID`,`PrevClassID`,`raceid`,`hairframe`,`gold`,`exp`,`hp`,`mp`,`Silver`,`Gems`,`Coins`,`MaxBagSlots`,`MaxBankSlots`,`MaxHouseSlots`,`MaxHouseItemSlots`,`intSTR`,`intINT`,`intDEX`,`intEND`,`intLUK`,`intCHA`,`intWIS`,`intStatPoints`,`strArmor`,`strSkills`,`strQuests`,`HasDragon`) VALUES ('
- q_1 = ')");'
- with open("chargen.php","a") as f:
- f.write("{}\n{}\n{}\n".format("<?php",'require("includes/config.php");','$conn = mysqli_connect($mysql_host,$mysql_user,$mysql_pass,$mysql_name);'))
- for info in uinfo:
- f.write("{}{}{}\n".format(str(q_0),str(str(info).replace('[','')).replace(']',''),str(q_1)))
- for chid in chids:
- q0 = '$array = array();'
- q1 = '$result = mysqli_query($conn,"SELECT ItemID FROM `df_items` WHERE Level={} AND EquipSpot={}");'.format(chid[1],"'Weapon'")
- q2 = "while($row = mysqli_fetch_array($result)){ array_push($array,$row['ItemID']); }"
- q3 = '$output = $array[rand(0,sizeof($array))];'
- q4 = 'mysqli_query($conn,"INSERT INTO `df_equipment`(`CharID`,`ItemID`,`StartingItem`,`count`,`Level`,`Exp`,`House`,`HouseItem`,`intEquipSlotPos`) VALUES ({},$output,1,1,1,0,0,0,0);");'.format(chid[0])
- q5 = '$array2 = array();'
- q6 = '$result = mysqli_query($conn,"SELECT ItemID FROM `df_items` WHERE Level={} AND EquipSpot={}");'.format(chid[1],"'Armor'")
- q7 = '$output2 = $array2[rand(0,sizeof($array2))];'
- q8 = 'mysqli_query($conn,"INSERT INTO `df_equipment`(`CharID`,`ItemID`,`StartingItem`,`count`,`Level`,`Exp`,`House`,`HouseItem`,`intEquipSlotPos`) VALUES ({},$output2,1,1,1,0,0,0,0);");'.format(chid[0])
- f.write("{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n".format(q0,q1,q2,q3,q4,q5,q6,q7,q8))
- f.write("{}".format("?>"))
- def w_db(num_gen):
- numchars = input("How many characters do you already have in the database: ")
- for z in xrange(num_gen):
- g = ["M","F"]
- mhairs = [1, 3, 4, 5, 6, 7, 8, 9]
- fhairs = [2, 11, 12, 13, 14, 15, 16, 17]
- c = []
- with open('usernames.txt','r') as r:
- usernames = r.readlines()
- username = usernames[rr(0,len(usernames))].rstrip()
- milli = "%03d" % rr(0,999)
- born = strftime("%Y-%m-%dT%H:%M:%S.{}".format(milli),gmtime(rr(1167631200,int(time()))))
- for x in xrange(12):
- c.append(str(hex(rr(16,255)).split('x')[1]).upper())
- cid, da, lvl, gender, haircolor, skincolor, basecolor, trimcolor, baseclass = (z+numchars+1),1,rr(1,81), g[rr(len(g))], rr(0,16777216), rr(0,16777216), rr(0,16777216), rr(0,16777216), rr(2,5)
- maxhp, maxmp, maxsp = 100+(20*(lvl-1)), 100+(5*(lvl-1)), 5*(lvl-1)
- chids.append([cid,lvl])
- if(lvl > 1):
- if(baseclass == 2):
- outcome = maxsp
- strength = rr(0,outcome+1)
- outcome = outcome - strength
- endurance = rr(0,outcome+1)
- outcome = outcome - endurance
- dexterity = rr(0,outcome+1)
- outcome = outcome - dexterity
- luck = rr(0,outcome+1)
- outcome = outcome - luck
- charisma = rr(0,outcome+1)
- outcome = outcome - charisma
- intelligence = rr(0,outcome+1)
- outcome = outcome - intelligence
- wisdom = rr(0,outcome+1)
- outcome = outcome - wisdom
- elif(baseclass == 3):
- outcome = maxsp
- intelligence = rr(0,outcome+1)
- outcome = outcome - intelligence
- endurance = rr(0,outcome+1)
- outcome = outcome - endurance
- dexterity = rr(0,outcome+1)
- outcome = outcome - dexterity
- wisdom = rr(0,outcome+1)
- outcome = outcome - wisdom
- strength = rr(0,outcome+1)
- outcome = outcome - strength
- luck = rr(0,outcome+1)
- outcome = outcome - luck
- charisma = rr(0,outcome+1)
- outcome = outcome - charisma
- else:
- outcome = maxsp
- dexterity = rr(0,outcome+1)
- outcome = outcome - dexterity
- strength = rr(0,outcome+1)
- outcome = outcome - strength
- endurance = rr(0,outcome+1)
- outcome = outcome - endurance
- luck = rr(0,outcome+1)
- outcome = outcome - luck
- charisma = rr(0,outcome+1)
- outcome = outcome - charisma
- intelligence = rr(0,outcome+1)
- outcome = outcome - intelligence
- wisdom = rr(0,outcome+1)
- outcome = outcome - wisdom
- else:
- strength, intelligence, dexterity, endurance, luck, charisma, wisdom = 0, 0, 0, 0, 0, 0, 0
- if(gender == "M"):
- hair = mhairs[rr(len(mhairs))]
- else:
- hair = fhairs[rr(len(mhairs))]
- uinfo.append([cid,0,username,lvl,da,"Human",born,gender,0,0,hair,haircolor,skincolor,basecolor,trimcolor,baseclass,baseclass,baseclass,1,1,rr(0,10000000),0,maxhp,maxmp,0,0,rr(0,10000000),20,5,0,0,strength,intelligence,dexterity,endurance,luck,charisma,wisdom,outcome,"0"*50,"0"*20,"0"*100,0])
- write()
- if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('-g', '--gen', action='store', default=True, help='Enter number of characters to generate.')
- args = parser.parse_args()
- if args.gen:
- w_db(int(args.gen))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement