import urllib # Adds Utility for url grabbing import re # adds Regular Expressions import os # adds OS functionality import string # adds string functionality print "This program will auto generate most Mob TP moves!\n" print "Please make sure to provide the list of names for each" print "move in a file located C:/mobskills/names.txt!\n" print "Names should be spelled exactly how they are in " print "the DSP database. An example would be Bubble " print "Shower. You should place it in the file on it's" print "own line and captialize both Bubble and Shower." print "Make sure to use _ instead of space just like " print "the database does or it will not work!\n" print "Example: Bubble_Shower\n" print "C:/mobskills/ is used to hold all the new files that will be made\n" dirList = os.listdir("C:/") hasFolder = 0 if 'mobskills' in dirList: hasFolder = 1 else: os.mkdir("C:/mobskills") fileList = os.listdir("C:/mobskills") if "names.txt" in fileList: start = raw_input("Please press any key to continue or hit \"CTRL + C\" to cancel.\n\n") else: start = raw_input("The names.txt file is missing and therefore I have no names to use! Please add the file and then hit any key!\n\n") ## Get names of all moves to be built! nameFile = open("C:/mobskills/names.txt",mode="r") ## Grab html Page for the move currently working on. for line in nameFile: name = line webPage = urllib.urlopen("http://wiki.ffxiclopedia.org/wiki/" + name) rWebPage = webPage.read() cleanName = name.strip() cleanName = cleanName.replace('_',' ') print "Script for " + cleanName + " is being made..." ## Drop page into a temporary file wTempFile = open("C:/mobskills/tempFile.txt","w") wTempFile.write(rWebPage) wTempFile.close() #print "Page has been saved temporarily for proper reading of "+ name.strip() + " script." +"\n\n" ## Start Clean up #print "Currently cleaning the html code...\n" rTempFile = open ("C:/mobskills/tempFile.txt","r") output = open("C:/mobskills/"+str(name).strip()+".lua","w") output.write('---------------------------------------------'+"\n") output.write('-- '+str(cleanName)+"\n") output.write('--'+"\n") ######################################################################################################## scriptType = 0 needEnfeeble = 0 #### Sets the flag for additional efect to 0 by default for line in rTempFile: if "
" in line: ##### Cleans up the Description description = line.replace("
","") description = description.replace("","") description = description.replace("","") description = re.sub('","") if "font" in description: description = description.replace("/font","") description = re.sub('','',description) description = re.sub("<.*?>","",description) output.write("-- Description: " + description.strip()+"\n") ################################################################################ ######### Check for number of physical hits ################################ ################################################################################ numberAtk = description.lower() if "fivefold" in numberAtk: numAtk = 5 elif "fourfold" in numberAtk: numAtk = 4 elif "threefold" in numberAtk: numAtk = 3 elif "twofold" in numberAtk: numAtk = 2 else: numAtk = 1 ################################################################################ ########## Checks if additional effects are needed ############################# ################################################################################ addEffect = description.lower() drain = 0 ### Sets drain or add hp to NO, by default dmgScript = 0 if 'deals' in addEffect: dmgScript = 1 elif 'damage' in addEffect: dmgScript = 1 if "additional" in addEffect: needEnfeeble = 1 #### Sets the flag so additonal effects are added effectName = re.sub('.*?effect:','',addEffect) addEffect = re.sub('.*?additional','',addEffect) if "drain" in description.lower(): ### Checks for added effect drain drain = 1 ################################################################################# ######### Looks for damage over time effects ################################ ################################################################################# dotEffect = 1 if 'bio' in effectName: effect = 'EFFECT_BIO' elif 'dia' in effectName: effect = 'EFFECT_DIA' elif 'poison' in effectName: effect = 'EFFECT_POISON' elif 'burn' in effectName: effect = 'EFFECT_BURN' elif 'choke' in effectName: effect = 'EFFECT_CHOKE' elif 'shock' in effectName: effect = 'EFFECT_SHOCK' elif 'frost' in effectName: effect = 'EFFECT_FROST' elif 'drown' in effectName: effect = 'EFFECT_DROWN' elif 'rasp' in effectName: effect = 'EFFECT_RASP' else: dotEffect = 0 ################################################################################# ######### Looks for stat down or reduce effects ################################ ################################################################################# downCount = 0 if 'down' in addEffect: ### Checks stat down type effects if 'dex' in addEffect: effect = "EFFECT_DEX_DOWN" elif 'str' in addEffect: effect = "EFFECT_STR_DOWN" elif 'vit' in addEffect: effect = "EFFECT_VIT_DOWN" elif 'int' in addEffect: effect = "EFFECT_INT_DOWN" elif 'mnd' in addEffect: effect = "EFFECT_MND_DOWN" elif 'dexterity' in addEffect: effect = "EFFECT_DEX_DOWN" elif 'strength' in addEffect: effect = "EFFECT_STR_DOWN" elif 'vitality' in addEffect: effect = "EFFECT_VIT_DOWN" elif 'intelligence' in addEffect: effect = "EFFECT_INT_DOWN" elif 'mind' in addEffect: effect = "EFFECT_MND_DOWN" downCount = downCount + 1 if "and" in addEffect: #### Checks if there is a second stat to be decreased secondEffect = re.sub('.*?and','',addEffect) ### Removes the first stat down we found in last run print "It is breaking at first point: " + secondEffect if 'dex' in secondEffect: effectTwo = "EFFECT_DEX_DOWN" elif 'str' in secondEffect: effectTwo = "EFFECT_STR_DOWN" elif 'vit' in secondEffect: effectTwo = "EFFECT_VIT_DOWN" elif 'int' in secondEffect: effectTwo = "EFFECT_INT_DOWN" elif 'mnd' in secondEffect: effectTwo = "EFFECT_MND_DOWN" elif 'dexterity' in secondEffect: effectTwo = "EFFECT_DEX_DOWN" elif 'strength' in secondEffect: effectTwo = "EFFECT_STR_DOWN" elif 'vitality' in secondEffect: effectTwo = "EFFECT_VIT_DOWN" elif 'intelligence' in secondEffect: effectTwo = "EFFECT_INT_DOWN" elif 'mind' in secondEffect: effectTwo = "EFFECT_MND_DOWN" elif 'def' in secondEffect: effectTwo = "EFFECT_DEFENSE_DOWN" downCount = downCount + 1 elif 'reduce' in addEffect: ### Checks stat down type effects if 'dex' in addEffect: effect = "EFFECT_DEX_DOWN" elif 'str' in addEffect: effect = "EFFECT_STR_DOWN" elif 'vit' in addEffect: effect = "EFFECT_VIT_DOWN" elif 'int' in addEffect: effect = "EFFECT_INT_DOWN" elif 'mnd' in addEffect: effect = "EFFECT_MND_DOWN" elif 'atk' in addEffect: effect = "EFFECT_ATTACK_DOWN" elif 'def' in addEffect: effect = "EFFECT_DEFENSE_DOWN" elif 'acc' in addEffect: effect = "EFFECT_ACCURACY_DOWN" elif 'eva' in addEffect: effect = "EFFECT_EVASION_DOWN" elif 'dexterity' in addEffect: effect = "EFFECT_DEX_DOWN" elif 'strength' in addEffect: effect = "EFFECT_STR_DOWN" elif 'vitality' in addEffect: effect = "EFFECT_VIT_DOWN" elif 'intelligence' in addEffect: effect = "EFFECT_INT_DOWN" elif 'mind' in addEffect: effect = "EFFECT_MND_DOWN" downCount = downCount + 1 if "and" in addEffect: #### Checks if there is a second stat to be decreased secondEffect = re.sub('.*?and','',addEffect) ### Removes the first stat down we found in last run if 'dex' in secondEffect: effectTwo = "EFFECT_DEX_DOWN" elif 'str' in secondEffect: effectTwo = "EFFECT_STR_DOWN" elif 'vit' in secondEffect: effectTwo = "EFFECT_VIT_DOWN" elif 'int' in secondEffect: effectTwo = "EFFECT_INT_DOWN" elif 'mnd' in secondEffect: effectTwo = "EFFECT_MND_DOWN" elif 'dexterity' in secondEffect: effectTwo = "EFFECT_DEX_DOWN" elif 'strength' in secondEffect: effectTwo = "EFFECT_STR_DOWN" elif 'vitality' in secondEffect: effectTwo = "EFFECT_VIT_DOWN" elif 'intelligence' in secondEffect: effectTwo = "EFFECT_INT_DOWN" elif 'mind' in secondEffect: effectTwo = "EFFECT_MND_DOWN" elif 'attack' in secondEffect: effectTwo = "EFFECT_ATTACK_DOWN" elif 'defense' in secondEffect: effectTwo = "EFFECT_DEFENSE_DOWN" elif 'accuracy' in secondEffect: effectTwo = "EFFECT_ACCURACY_DOWN" elif 'evasion' in secondEffect: effectTwo = "EFFECT_EVASION_DOWN" downCount = downCount + 1 ################################################################################ ### If none of the above apply then it is a debuff ############################# ### only! in ex blind,silence etc. ############################# ################################################################################ debufEffect = 0 if downCount == 0 and dotEffect == 0: debufEffect = 1 if 'silence' in addEffect: effect = 'EFFECT_SILENCE' elif 'blind' in addEffect: effect = 'EFFECT_BLINDNESS' elif 'bind' in addEffect: effect = 'EFFECT_BIND' elif 'sleep' is addEffect: effect = 'EFFECT_SLEEP' elif 'slow' in addEffect: effect = 'EFFECT_SLOW' elif 'gravity' in addEffect: effect = 'EFFECT_WEIGHT' elif 'paralysis' in addEffect: effect = 'EFFECT_PARALYSIS' elif 'paralyze' in addEffect: effect = 'EFFECT_PARALYSIS' elif 'curse' in addEffect: effect = 'EFFECT_CURSE' elif 'stun' in addEffect: effect = 'EFFECT_STUN' elif 'knockback' in addEffect: effect = 'EFFECT_KNOCKBACK' ################################################################################ ########## Checks for changes based off TP ############################# ################################################################################ tpLine = description.lower() ### Defines the string we check for added TP benefits elementLine = tpLine if "varies" in tpLine: #### Checks to see if the move changes based off TP if "accuracy" in tpLine: tpBonus = "TP_ACC_VARIES,1,2,3" elif "critical" in tpLine: tpBonus = "TP_CRIT_VARIES,1,2,3" elif "attack" in tpLine: tpBonus = "TP_ATK_VARIES,1,2,3" elif "damage" in tpLine: tpBonus = "TP_DMG_VARIES,1,2,3" else: #### Sets the default to NO change absed off TP tpBonus = "TP_NO_EFFECT" ################################################################################ ########## Checks damage type. In example: Physical, Magical etc.############### ################################################################################ elif "Spell Type" in line: type = line.replace("","") type = type.replace("","") type = type.replace("Spell","") type = re.sub("<.*?>","",type) type = re.sub("\)
","",type) type = re.sub('\(','',type) type = type.replace(")
","") output.write("-- "+ type.strip() + "\n") output.write("-- \n") output.write("-- \n") elementLine = type.lower() if "Magical" in line: scriptType = 1 if "fire" in elementLine: element = "FIRE" elif "water" in elementLine: element = "WATER" elif "ice" in elementLine: element = "ICE" elif "earth" in elementLine: element = "EARTH" elif "thunder" in elementLine: element = "THUNDER" elif "wind" in elementLine: element = "WIND" elif "dark" in elementLine: element = "DARK" elif "light" in elementLine: element = "LIGHT" elif "Physical" in type: scriptType = 2 physParamLine = type.lower() if "slashing" in physParamLine: physParam = "MOBPARAM_SLASH" elif "blunt" in physParamLine: physParam = "MOBPARAM_BLUNT" elif "pierc" in physParamLine: physParam = "MOBPARAM_PIERCE" elif "hand" in physParamLine: physParam = "MOBPARAM_H2H" elif "h2h" in physParamLine: physParam = "MOBPARAM_H2H" else: physParam = "MOBPARAM_NONE" elif "Enfeebling" in line: ### Catches none damage moves that are effect based only! scriptType = 3 if dmgScript == 0: ### Override check, force to enfeeble because we did not find the word damage or deals in description! scriptType = 3 ################################################################################ ########## Checks shadow behavior, in ex. Wipes shadows ############### ################################################################################ if "Utsusemi/Blink absorb:" in line: shadows = line output.write("-- " + shadows.strip() + "\n") shadows = shadows.lower() if "wipe" in shadows: shadows = "MOBPARAM_WIPE_SHADOWS" elif "1" in shadows: shadows = "MOBPARAM_1_SHADOW" elif "2" in shadows: shadows = "MOBPARAM_2_SHADOW" elif "3" in shadows: shadows = "MOBPARAM_3_SHADOW" else: shadows = "MOBPARAM_IGNORE_SHADOWS" ################################################################################ ########## Adds the required scripts for the script made ############### ################################################################################ output.write('---------------------------------------------'+"\n") output.write("require(\"/scripts/globals/settings\");\nrequire(\"/scripts/globals/status\");\nrequire(\"/scripts/globals/monstertpmoves\");\n") output.write('---------------------------------------------'+"\n") output.write("function OnMobWeaponSkill(target, mob, skill)\n") ################################################################################ ########## Non-Blue mage version moves require this filter ################ ########## to find the data we pulled above ################ ################################################################################ elif "
  • " in line: line = line.replace("
  • ","") line = line.replace("","") if "Type:" in line: # Checks if magical or physical type = line output.write("-- " + type.strip() + "\n") if "Magical" in line: ### Checks and sets the Magic damage and elemental type in ex. Fire damage scriptType = 1 if "fire" in elementLine: element = "FIRE" elif "water" in elementLine: element = "WATER" elif "ice" in elementLine: element = "ICE" elif "earth" in elementLine: element = "EARTH" elif "thunder" in elementLine: element = "THUNDER" elif "wind" in elementLine: element = "WIND" elif "dark" in elementLine: element = "DARK" elif "light" in elementLine: element = "LIGHT" elif "Breath" in line: ### Checks and sets the Magic damage and elemental type in ex. Fire damage scriptType = 1 if "fire" in elementLine: element = "FIRE" elif "water" in elementLine: element = "WATER" elif "ice" in elementLine: element = "ICE" elif "earth" in elementLine: element = "EARTH" elif "thunder" in elementLine: element = "THUNDER" elif "wind" in elementLine: element = "WIND" elif "dark" in elementLine: element = "DARK" elif "light" in elementLine: element = "LIGHT" else: scriptType = 2 physParamLine = line.lower() if "slashing" in physParamLine: physParam = "MOBPARAM_BLUNT" elif "blunt" in physParamLine: physParam = "MOBPARAM_BLUNT" elif "pierc" in physParamLine: physParam = "MOBPARAM_PIERCE" elif "hand" in physParamLine: physParam = "MOBPARAM_H2H" elif "h2h" in physParamLine: physParam = "MOBPARAM_H2H" else: physParam = "MOBPARAM_NONE" elif "Physical" in line: ### Checks and sets the Physical damage type in ex. Blunt damage scriptType = 2 physParamLine = line.lower() if "slashing" in physParamLine: physParam = "MOBPARAM_BLUNT" elif "blunt" in physParamLine: physParam = "MOBPARAM_BLUNT" elif "pierc" in physParamLine: physParam = "MOBPARAM_PIERCE" elif "hand" in physParamLine: physParam = "MOBPARAM_H2H" elif "h2h" in physParamLine: physParam = "MOBPARAM_H2H" else: physParam = "MOBPARAM_NONE" elif "Enfeebling" in line: ### Checks if the script is enfeebling only in ex. no damage but gives effect of sleep. scriptType = 3 elif "Enhancing" in line: ### Checks if the script is enfeebling only in ex. no damage but gives effect of sleep. scriptType = 4 elif "Utsusemi/Blink absorb:" in line: ### Check for shadows behavior if it wipes or ignores or such. shadows = line output.write("-- " + shadows.strip() + "\n") if "Ignore" in shadows: shadows = "MOBPARAM_IGNORE_SHADOWS" elif "Wipe" in shadows: shadows = "MOBPARAM_WIPE_SHADOWS" elif "1" in shadows: shadows = "MOBPARAM_1_SHADOW" elif "2" in shadows: shadows = "MOBPARAM_2_SHADOW" elif "3" in shadows: shadows = "MOBPARAM_3_SHADOW" elif "Range:" in line: ## Looks for details on range, more for nice info but not really needed. range = line range = re.sub('','',range) range = re.sub('.*?/a','',range) output.write("-- " + range.strip() + "\n") elif "Notes:" in line: ### Looks for additional notes that can help determine how the move works notes = re.sub('<.*?>','',line) notes = notes.replace('','') ############################################################################### ######### Adds required scripts that the mob tp move needs to function ###### ############################################################################### output.write("-- " + notes.strip() + "\n") output.write('---------------------------------------------'+"\n") output.write("require(\"/scripts/globals/settings\");\nrequire(\"/scripts/globals/status\");\nrequire(\"/scripts/globals/monstertpmoves\");\n\n") output.write('---------------------------------------------'+"\n") output.write("function OnMobWeaponSkill(target, mob, skill)\n") ################################################################################ ########## Checks if there is an enfeeble effect that has to be ############## ########## added and if there is more then one ############## ################################################################################ if needEnfeeble == 1: if downCount > 0: output.write("\n\n local message = MSG_MISS;\n") output.write(" local typeEffect = "+effect+";\n") ### Adds the effect variable from earlier output.write(" if(target:hasStatusEffect(typeEffect) == false) then\n") output.write(" local statmod = MOD_INT;\n") output.write(" local resist = applyPlayerResistance(mob,skill,target,mob:getMod(statmod)-target:getMod(statmod),0,5);\n") output.write(" if(resist > 0.5) then\n") output.write(" target:addStatusEffect(typeEffect,1,0,60); -- Please set power,tic and duration. Defaults power = 1, tic = 0 duration = 60\n") output.write(" end\n") output.write(" end\n") downCount = downCount - 1 if downCount > 0: ### Checks if there is a second down stat output.write(" typeEffectTwo = "+effectTwo+";\n") ### Adds the second effect variable from earlier output.write(" if(target:hasStatusEffect(typeEffectTwo) == false) then\n") output.write(" local statmod = MOD_INT;\n") output.write(" local resist = applyPlayerResistance(mob,skill,target,mob:getMod(statmod)-target:getMod(statmod),0,5);\n") output.write(" if(resist > 0.5) then\n") output.write(" target:addStatusEffect(typeEffectTwo,1,0,60); -- Please set power,tic and duration. Defaults power = 1, tic = 0 duration = 60\n") output.write(" end\n") output.write(" end\n") if dotEffect == 1 or debufEffect == 1: print "Additional effect was scripted but you will need to manually add in the power,tic and duration!" output.write("\n\n local typeEffect = "+effect+";\n") ### Adds the effect variable from earlier output.write(" if(target:hasStatusEffect(typeEffect) == false) then\n") output.write(" local statmod = MOD_INT;\n") output.write(" local resist = applyPlayerResistance(mob,skill,target,mob:getMod(statmod)-target:getMod(statmod),0,5);\n") output.write(" if(resist > 0.5) then\n") output.write(" target:addStatusEffect(typeEffect,1,0,60); -- Please set power,tic and duration. Defaults power = 1, tic = 0 duration = 60\n") output.write(" end\n") output.write(" end\n") ################################################################################ ########## Calls the script types set from earlier and based off ############## ########## the result adds in the appropriate calculations ############## ################################################################################ if scriptType == 1: output.write(" local dmgmod = 1;\n") output.write(" local accmod = 1;\n") output.write(" local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,accmod,dmgmod,"+tpBonus+");\n") output.write(" local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_"+ element +","+shadows+");\n") output.write(" target:delHP(dmg);\n") if drain == 1: ### Adds heal for additional effect drain output.write(" mob:addHP(dmg);\n") output.write(" return dmg;\n") print "This a Magical based move! Please check that the TP effect is set properly!" elif scriptType == 2: output.write(" local numhits = "+ str(numAtk) +";\n") output.write(" local accmod = 1;\n") output.write(" local dmgmod = 1;\n") output.write(" local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,"+tpBonus+");\n") output.write(" local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,"+physParam+",info.hitslanded);\n") output.write(" target:delHP(dmg);\n") if drain == 1: ### Adds heal for additional effect drain output.write(" mob:addHP(dmg);\n") output.write(" return dmg;\n") print "This is a Physical move and requires you to check MOBPARAM." elif scriptType == 3: print "Enfeeble type move, script requires to be manually edited, only a default layout was made!" output.write("\n\n local message = MSG_MISS;\n") output.write(" local typeEffect = EFFECT_NAME; -- Add effect name here\n\n") output.write(" if(target:hasStatusEffect(typeEffect) == false) then\n") output.write(" local accrand = math.random(1,2);\n") output.write(" if(accrand == 1) then\n") output.write(" local statmod = MOD_INT;\n") output.write(" local resist = applyPlayerResistance(mob,skill,target,mob:getMod(statmod)-target:getMod(statmod),0,5);\n") output.write(" if(resist > 0.5) then\n") output.write(" message = MSG_ENFEEB_IS;\n") output.write(" target:addStatusEffect(typeEffect,1,0,60); -- Please set power,tic and duration. Defaults power = 1, tic = 0 duration = 60\n") output.write(" end\n") output.write(" end\n") output.write(" else\n") output.write(" message = MSG_NO_EFFECT;\n") output.write(" end\n") output.write(" skill:setMsg(message);\n") output.write(" return typeEffect;\n") elif scriptType == 4: print "Enhancing type move, script requires to be manually edited, only a default layout was made!" output.write("\n\n local power = 1;\n") output.write(" local tic = 0;\n") output.write(" local duration = 60;\n\n") output.write(" local typeEffect = EFFECT_NAME;\n") output.write(" skill:setMsg(MSG_BUFF);\n") output.write(" if(mob:hasStatusEffect(typeEffect) == true) then\n") output.write(" local oldEffect = mob:getStatusEffect(typeEffect);\n") output.write(" local oldEffect:setPower(power);\n") output.write(" local oldEffect:setDuration(duration);\n") output.write(" else\n") output.write(" mob:addStatusEffect(typeEffect,power,tic,duration);\n") output.write(" return typeEffect;\n") elif scriptType == 0: print name.strip() +" has been made!" output.write("end;") output.close() ### Closes the script the file made print "\n\n" nameFile.close() rTempFile.close() os.remove("C:/mobskills/tempFile.txt") finish = raw_input("Please hit enter to close the program")