Refactor: Abyss Locust descriptions

closes #803
This commit is contained in:
Wofsauge committed 2025-02-27 22:04:10 +01:00
1 parent 460eaeee01
commit 49be3838a0
8 files changed
+413 -290

No files matched your search

+132 -14
View File
@@ -3,14 +3,14 @@
import xml.etree.ElementTree as ET
GENERATE_REP_PLUS = True
GENERATE_REP_PLUS = False
filePath = "..\\..\\..\\..\\resources-dlc3\\"
writeToFile = "../../features/eid_xmldata.lua"
filePath = "..\\..\\resources-dlc3\\"
writeToFile = "features/eid_xmldata.lua"
if GENERATE_REP_PLUS:
filePath = "..\\..\\..\\..\\extracted_resources\\resources\\"
writeToFile = "../../features/eid_xmldata_rep+.lua"
filePath = "..\\..\\extracted_resources\\resources\\"
writeToFile = "features/eid_xmldata_rep+.lua"
# take second element for sort
def sortByID(elem):
@@ -22,31 +22,33 @@ maxItemID = 0
cardMetadatas = []
pillMetadatas = []
entityNames = []
locusts = []
locustColors = []
recipeIngredients = {}
#Poop, Penny
# Poop, Penny
recipeIngredients["_"] = 29
recipeIngredients["."] = 8
#Red, Soul, Black Heart
# Red, Soul, Black Heart
recipeIngredients["h"] = 1
recipeIngredients["s"] = 2
recipeIngredients["b"] = 3
#Key, Bomb, Card
# Key, Bomb, Card
recipeIngredients["/"] = 12
recipeIngredients["v"] = 15
recipeIngredients["["] = 21
#Gold Heart, Eternal Heart, Pill
# Gold Heart, Eternal Heart, Pill
recipeIngredients["g"] = 5
recipeIngredients["e"] = 4
recipeIngredients["("] = 22
#Rotten Heart, Gold Key, Giga Bomb
# Rotten Heart, Gold Key, Giga Bomb
recipeIngredients["r"] = 7
recipeIngredients["|"] = 13
recipeIngredients["V"] = 17
#Gold Bomb, Bone Heart
# Gold Bomb, Bone Heart
recipeIngredients["^"] = 16
recipeIngredients["B"] = 6
#Dice Shard, Cracked Key
# Dice Shard, Cracked Key
recipeIngredients["?"] = 24
recipeIngredients["~"] = 25
@@ -110,7 +112,78 @@ for entity in entitiesXML.findall('entity'):
theName = theName[1:].replace('_',' ').title()
entityNames.append({ "id": theID, "name": theName })
#Write xml file
# Read locusts.xml
locustsXML = ET.parse(filePath+'locusts.xml').getroot()
for color in locustsXML.findall('color'):
name = color.get('name')
c_r = color.get('r') or 0
c_g = color.get('g') or 0
c_b = color.get('b') or 0
c_or = color.get('or') or 0
c_og = color.get('og') or 0
c_ob = color.get('ob') or 0
locustColors.append({"name": name, "r":c_r, "g":c_g, "b":c_b, "or":c_or, "og":c_og, "ob":c_ob})
for locust in locustsXML.findall('locust'):
id = locust.get('id')
# locust entries can have multiple colors defined
color = locust.get('color') or "default"
colors = []
for c in color.split("&"):
colors.append(c.split("-")[len(c.split("-"))-1])
scale = locust.get('scale') or 1
speed = locust.get('speed') or 1
locustFlags1 = locust.get('locustFlags') or locust.get('locustFlag') or -1
locustFlags2 = locust.get('locustFlags2') or -1
locustFlags3 = locust.get('locustFlags3') or -1
tearFlags1 = locust.get('tearFlags') or -1
tearFlags2 = locust.get('tearFlags2') or -1
tearFlags3 = locust.get('tearFlags3') or -1
procChance1 = locust.get('procChance') or 1
procChance2 = locust.get('procChance2') or 1
procChance3 = locust.get('procChance3') or 1
count = locust.get('count') or 1
mutexFlags2 = locust.get('mutexFlags2') or 0
damageMultiplier1 = locust.get('damageMultiplier') or 1
damageMultiplier2 = locust.get('damageMultiplier2') or 1
foundExistingLocust = False
for savedLocust in locusts:
if savedLocust["id"] == id:
savedLocust["count"] = savedLocust["count"] + 1
foundExistingLocust = True
break
if not foundExistingLocust:
locusts.append(
{
"id": id,
"color": colors,
"scale": scale,
"speed": speed,
"count": count,
"locustFlags1": list(map(int, str(locustFlags1).split(" "))),
"locustFlags2": list(map(int, str(locustFlags2).split(" "))),
"locustFlags3": list(map(int, str(locustFlags3).split(" "))),
"tearFlags1": list(map(int, str(tearFlags1).split(" "))),
"tearFlags2": list(map(int, str(tearFlags2).split(" "))),
"tearFlags3": list(map(int, str(tearFlags3).split(" "))),
"procChance1": procChance1,
"procChance2": procChance2,
"procChance3": procChance3,
"damageMultiplier1": damageMultiplier1,
"damageMultiplier2": damageMultiplier2,
"mutexFlags2": mutexFlags2,
}
)
# Write xml file
newfile = open(writeToFile, "w")
newfile.write("--This file was autogenerated using 'lookuptable_generator.py' found in the scripts folder\n")
@@ -155,6 +228,52 @@ for pill in pillMetadatas:
newfile.write("}\n\n")
newfile.write("-- locust colors for Abyss\n")
newfile.write("EID.XMLLocustColors = {")
for color in locustColors:
tempString = ""
tempString += "[\""+str(color["name"])+"\"] = {"
tempString += str(color["r"])+", "
tempString += str(color["g"])+", "
tempString += str(color["b"])+", "
tempString += str(color["or"])+", "
tempString += str(color["og"])+", "
tempString += str(color["ob"])+"}, "
newfile.write(tempString)
newfile.write("}\n\n")
newfile.write("-- effect storage for each locust generated by Abyss\n")
newfile.write("EID.XMLLocusts = {")
counter = 0
for locust in locusts:
counter = counter+1
tempString = ""
tempString += "["+str(locust['id'])+"] = {"
tempString += ""+str(locust['color']).replace("[","{").replace("]","}")+", "
tempString += str(locust['count'])+", "
tempString += str(locust['scale'])+", "
tempString += str(locust['speed'])+", "
# locustFlags and tearFLags can have space seperated values in them
tempString += str(locust['locustFlags1']).replace("[","{").replace("]","}")+", "
tempString += str(locust['locustFlags2']).replace("[","{").replace("]","}")+", "
tempString += str(locust['locustFlags3']).replace("[","{").replace("]","}")+", "
tempString += str(locust['tearFlags1']).replace("[","{").replace("]","}")+", "
tempString += str(locust['tearFlags2']).replace("[","{").replace("]","}")+", "
tempString += str(locust['tearFlags3']).replace("[","{").replace("]","}")+", "
tempString += str(locust['procChance1'])+", "
tempString += str(locust['procChance2'])+", "
tempString += str(locust['procChance3'])+", "
tempString += str(locust['damageMultiplier1'])+", "
tempString += str(locust['damageMultiplier2'])+", "
tempString += str(locust['mutexFlags2'])
tempString += "}, "
if counter > 50:
newfile.write(tempString+"\n")
counter = 0
else:
newfile.write(tempString)
newfile.write("}\n\n")
newfile.write("--The name of each entity, for use in glitched item descriptions\n")
newfile.write("EID.XMLEntityNames = {")
@@ -172,4 +291,3 @@ newfile.write("}\n\n")
newfile.close()
print("SUCCESS")