Skip to content

Commit

Permalink
Fixed language intergration for pal names. Added Bellanoir. Fixed the…
Browse files Browse the repository at this point in the history
… MaxHP value as the game now handles this automatically.
  • Loading branch information
EternalWraith committed Apr 5, 2024
1 parent daa76e5 commit 3a5a0e7
Show file tree
Hide file tree
Showing 18 changed files with 6,492 additions and 11,022 deletions.
4 changes: 2 additions & 2 deletions CxFreezeCompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
base = "Win32GUI" if sys.platform == "win32" else None

setup(
name = "PalEdit v0.7",
version = "0.7",
name = "PalEdit v0.7.2",
version = "0.7.2",
description = "A simple tool for editing PalWorld saves",
options={"build_exe": build_options},
executables=[Executable("PalEdit.py", base=base, icon="palworld_pal_edit/resources/MossandaIcon.ico")],
Expand Down
Binary file added assets/Bellanoir Libero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Bellanoir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/RibbunyTest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
648 changes: 648 additions & 0 deletions pals/error_0.json

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions palworld_pal_edit/PalEdit.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def skip_encode(


class PalEditConfig:
version = "0.7.2"
version = "0.8"
ftsize = 18
font = "Microsoft YaHei"
badskill = "#DE3C3A"
Expand Down Expand Up @@ -660,6 +660,8 @@ def loadpal(self, paldata):
self.palbox[self.players[p]] = []
self.containers = {}
nullmoves = []

erroredpals = []
for i in paldata:
try:
p = PalInfo.PalEntity(i)
Expand All @@ -686,6 +688,10 @@ def loadpal(self, paldata):
# self.players[pl] = plguid
else:
self.unknown.append(str(e))
try:
erroredpals.append(i)
except:
erroredpals.append(None)
logger.error(f"Error occured on {i['key']['InstanceId']['value']}", exc_info=True)
# print(f"Error occured on {i['key']['InstanceId']['value']}: {e.__class__.__name__}: {str(e)}")
# traceback.print_exception(e)
Expand All @@ -700,8 +706,11 @@ def loadpal(self, paldata):
logger.Space()
logger.info(f"NOTE: Unknown list is a list of pals that could not be loaded")
logger.warning(f"Unknown list contains {len(self.unknown)} entries")
for i in self.unknown:
logger.warning(" %s" % str(i))
for i in range(0, len(self.unknown)):
logger.warning(" %s" % str(self.unknown[i]))
with open(f"pals/error_{i}.json", "wb") as errorfile:
errorfile.write(json.dumps(erroredpals[i], indent=4, cls=UUIDEncoder).encode('utf-8'))


logger.Space()
logger.debug(f"{len(self.players)} players found:")
Expand Down
150 changes: 36 additions & 114 deletions palworld_pal_edit/PalInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ def SetRankWorkSpeed(self, value):
self._obj["Rank_CraftSpeed"]["value"] = value

def GetMaxHP(self):
return self._obj['MaxHP']['value']['Value']['value']
del self._obj['MaxHP']
return # We dont need to get this anymore; its gone

#return self._obj['MaxHP']['value']['Value']['value']

def CalculateIngameStats(self):
LEVEL = self.GetLevel()
Expand Down Expand Up @@ -415,6 +418,8 @@ def CalculateIngameStats(self):


def UpdateMaxHP(self):
return #this seems to be handled by the game itself now; impressive

if self.IsTower() or self.IsHuman():
return
new_hp = self.CalculateIngameStats()["HP"]
Expand Down Expand Up @@ -840,34 +845,30 @@ def LoadPals(lang="en-GB"):
if lang is not None and not os.path.exists(f"%s/resources/data/{lang}/pals.json" % (module_dir)):
lang = "en-GB"

# PalCodeMapping = {}
# with open("%s/resources/data/pals.json" % (module_dir), "r", encoding="utf8") as palfile:
# pals = json.load(palfile)
# PalCodeMapping = {pal['CodeName']: pal['Name'] for pal in pals['values']}
with open(f"%s/resources/data/{lang}/pals.json" % (module_dir), "r",
encoding="utf8") as palfile:
PalSpecies = {}
PalLearnSet = {}
for i in json.loads(palfile.read())["values"]:
# try:
# img = Image.open(module_dir + f'/resources/{i["Name"]}.png').resize((240, 240))
# with open(module_dir + f'/resources/pals/{i["CodeName"]}.png', 'wb') as f:
# img.save(f)
# except Exception as e:
# traceback.print_exception(e)
h = "Human" in i
t = "Tower" in i
p = i["Type"][0]
s = "None"
if len(i["Type"]) == 2:
s = i["Type"][1]
PalSpecies[i["CodeName"]] = PalObject(i["Name"], i["CodeName"], p, s, h, t,
i["Scaling"] if "Scaling" in i else None,
i["Suitabilities"] if "Suitabilities" in i else {})
if t:
PalSpecies[i["CodeName"]]._suits = PalSpecies[i["CodeName"].replace("GYM_", "")]._suits
PalSpecies[i["CodeName"]]._scaling = PalSpecies[i["CodeName"].replace("GYM_", "")]._scaling
PalLearnSet[i["CodeName"]] = i["Moveset"] if not t else PalLearnSet[i["CodeName"].replace("GYM_", "")]
with open("%s/resources/data/pals.json" % (module_dir), "r",
encoding="utf8") as datafile:
with open(f"%s/resources/data/{lang}/pals.json" % (module_dir), "r",
encoding="utf8") as palfile:
PalSpecies = {}
PalLearnSet = {}

d = json.loads(datafile.read())
l = json.loads(palfile.read())

for i in d["values"]:
h = "Human" in i
t = "Tower" in i
p = i["Type"][0]
s = "None"
if len(i["Type"]) == 2:
s = i["Type"][1]
PalSpecies[i["CodeName"]] = PalObject(l[i["CodeName"]], i["CodeName"], p, s, h, t,
i["Scaling"] if "Scaling" in i else None,
i["Suitabilities"] if "Suitabilities" in i else {})
if t:
PalSpecies[i["CodeName"]]._suits = PalSpecies[i["CodeName"].replace("GYM_", "")]._suits
PalSpecies[i["CodeName"]]._scaling = PalSpecies[i["CodeName"].replace("GYM_", "")]._scaling
PalLearnSet[i["CodeName"]] = i["Moveset"] if not t else PalLearnSet[i["CodeName"].replace("GYM_", "")]


LoadPals()
Expand Down Expand Up @@ -966,92 +967,13 @@ def find(name):
return "None"

if __name__ == "__main__":
# Convert Pals -> Moveset from Name to CodeName for i18n
"""with open("%s/resources/data/pals.json" % (module_dir), "r", encoding="utf-8") as f:
pals = json.load(f)
for pal in pals['values']:
if 'Moveset' in pal:
new_moveset = {}
for move_name in pal['Moveset']:
move_id = pal['Moveset'][move_name]
if find(move_name) != "None":
new_moveset[find(move_name)] = move_id
elif move_name in PalAttacks:
new_moveset[move_name] = move_id
else:
print(f"Error: Invalid {move_name}")
pal['Moveset'] = new_moveset
with open("%s/resources/data/pals.json" % (module_dir), "w", encoding="utf-8") as f:
json.dump(pals, f, indent=4)
"""

with open(f"%s/resources/data/passives.json" % (module_dir), "r", encoding="utf-8") as f:
ps = json.load(f)
o = {}
for p in ps['values']:
o[p["CodeName"]] = {
"Rating": p["Rating"],
}
with open(f"%s/resources/data/passives.json" % (module_dir), "w", encoding="utf-8") as f:
json.dump(o, f, indent=4, ensure_ascii=False)

# Debug algorithms go here

##
##
## if True:
## import bs4 as bsoup
## import urllib.request as ureq
##
##
##
## with open(module_dir+"/resources/data/pals.json", "r+", encoding="utf8") as palfile:
## p = json.loads(palfile.read())
## palfile.seek(0)
## for pal in p['values']:
## pal["Moveset"] = {}
## if not "Human" in pal and not "Tower" in pal:
## n = pal["Name"].lower().replace(" ", "-")
## headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'}
## req = ureq.Request(f"http://palworld.gg/pal/{n}", None, headers)
## src = ureq.urlopen(req)
## soup = bsoup.BeautifulSoup(src, "lxml")
##
## con = soup.find_all("div", {"class": "active skills"})
## if len(con) > 0:
## for item in con[0].find_all("div", {"class": "item"}):
##
## name = item.find("div", {"class": "name"}).text
## level = item.find("div", {"class": "level"})
##
## if not level == None:
## level = int(level.text.replace("- Lv ", ""))
## pal["Moveset"][name] = level
## json.dump(p, palfile, indent=4)
##
##
## if True:
##
## codes = {}
## with open("data.txt", "r") as file:
## for line in file:
## l = line.replace("\t", " ").replace("\n", "")
## c, n = l.split(" ", 1)
## codes[n] = c
##
## def sortStuff(e):
## return e["Name"]
## debugOutput.sort(key=sortStuff)
##
## for i in debugOutput:
## if i["Name"] in codes:
## i["CodeName"] = codes[i["Name"]]
## codes.pop(i["Name"])
##
## for i in codes:
## debugOutput.append({"CodeName": codes[i], "Name": i, "Type": "", "Power": 0})
## with open(module_dir+"/resources/data/attacks.json", "w", encoding="utf8") as attackfile:
## json.dump({"values": debugOutput}, attackfile, indent=4)
#from PIL import ImageTk, Image
#Image.open(f'../assets/Bellanoir.png').resize((240, 240)).save(f"resources/pals/NightLady.png")
#Image.open(f'../assets/Bellanoir Libero.png').resize((240, 240)).save(f"resources/pals/NightLady_Dark.png")

pass


def RecieveLogger(l):
Expand Down
39 changes: 38 additions & 1 deletion palworld_pal_edit/resources/data/attacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
},
"EPalWazaID::DarkLegion": {
"Type": "Dark",
"Power": 0
"Power": 160
},
"EPalWazaID::Unique_BlackGriffon_TackleLaser": {
"Type": "Dark",
Expand Down Expand Up @@ -441,6 +441,43 @@
"GYM_Horus"
]
},
"EPalWazaID::Unique_NightLady_FlameNightmare": {
"Type": "Dark",
"Power": 130,
"Exclusive": [
"NightLady_Dark"
]
},
"EPalWazaID::Unique_NightLady_WarpBeam": {
"Type": "Dark",
"Power": 160,
"Exclusive": [
"NightLady_Dark"
]
},
"EPalWazaID::Unique_NightLady_WarpBeam_Straight": {
"Type": "Dark",
"Power": 140,
"Exclusive": [
"NightLady"
]
},
"EPalWazaID::DarkCanon": {
"Type": "Dark",
"Power": 50
},
"EPalWazaID::DarkPulse": {
"Type": "Dark",
"Power": 40
},
"EPalWazaID::DarkArrow": {
"Type": "Dark",
"Power": 65
},
"EPalWazaID::Apocalypse": {
"Type": "Dark",
"Power": 110
},
"EPalWazaID::ThunderFunnel": {
"Type": "Electric",
"Power": 65
Expand Down
9 changes: 8 additions & 1 deletion palworld_pal_edit/resources/data/en-GB/attacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,12 @@
"EPalWazaID::Unique_BlackCentaur_TwoSpearRushes": "Twin Spears",
"EPalWazaID::Unique_VolcanicMonster_MagmaAttack": "Volcanic Burst",
"EPalWazaID::WindCutter": "Wind Cutter",
"EPalWazaID::WaterWave": "en Text"
"EPalWazaID::WaterWave": "en Text",
"EPalWazaID::Unique_NightLady_FlameNightmare": "Flame Waltz",
"EPalWazaID::Unique_NightLady_WarpBeam": "Nightmare Bloom",
"EPalWazaID::Unique_NightLady_WarpBeam_Straight": "Nightmare Ray",
"EPalWazaID::DarkCanon": "Dark Cannon",
"EPalWazaID::DarkPulse": "Umbral Surge",
"EPalWazaID::DarkArrow": "Dark Arrow",
"EPalWazaID::Apocalypse": "Apocalypse"
}
Loading

0 comments on commit 3a5a0e7

Please sign in to comment.