Skip to content

Commit

Permalink
Merge pull request #57 from JediKnightChan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JediKnightChan authored Dec 2, 2024
2 parents 2319515 + c9634d8 commit 5ca5a8d
Show file tree
Hide file tree
Showing 14 changed files with 1,004 additions and 22 deletions.
8 changes: 8 additions & 0 deletions Config/DefaultGameplayTags.ini
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ NetIndexFirstBitSegment=16
+GameplayTagList=(Tag="GameplayEvent.Stun.Short",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.Stun.Standard",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.TestAction",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.CurrencyPlate.Refresh",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.LoadingScreen.Hide",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.LoadingScreen.Show",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.Matchmaking.Cancel",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.Matchmaking.Start",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.MatchmakingPopup",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.MatchmakingPopup.Hide",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.MatchmakingPopup.Show",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.Weapon.BottomPercentAction",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.Weapon.BottomPercentAction.Cancelled",DevComment="")
+GameplayTagList=(Tag="GameplayEvent.UI.Weapon.BottomPercentAction.Started",DevComment="")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Check out our [Wiki](https://github.com/JediKnightChan/EternalCrusadeResurrectio

- C++ Unreal Engine 5 project
- Customization system for modular characters (material customization, mesh customization)
- Epic Online Services P2P matchmaking (users can create their own matches), including Linux Dedicated Servers
- Epic Online Services P2P matchmaking (users can create their own matches), including Linux Dedicated Servers, Friends List, Parties
- Python Scripts for automation of restoring non-exportable or hardly-exportable data for an unpacked UE4 game (socket
data, maps data, materials, references to materials within meshes)
- Enhanced Input Subsystem is used for input (borrowed from Lyra)
Expand Down
61 changes: 61 additions & 0 deletions Script/Python/ItemMigrationEC/ec_to_ecr/skill_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import json
import os

import pandas as pd


def make_ecr_skill_tree_skill_row(raw_name, text_name, lamp_cost, min_level, required_node, granted_gameplay_items,
node_type, image):
return {
'---': raw_name,
'Display Name': text_name,
'Is Enabled': True,
'Lamp Cost': lamp_cost,
'Min Level': min_level,
'Required Node': required_node,
'Granted Gameplay Item': granted_gameplay_items,
'Type': node_type,
'Icon Image': image
}


def convert_csv_to_ingame_csv(in_csv, out_csv, faction_dir):
df = pd.read_csv(in_csv)
df = df.fillna("")

new_data = []
for i, row in df.iterrows():
row = row.to_dict()
item_name = row.get("Progression")

if row.get("ItemReward"):
node_type = "GameplayItem"
elif "mastery" in row.get("Progression").lower():
node_type = "LpCostReduce"
elif "classnode" in row.get("Progression").lower():
node_type = "ClassUnlock"
else:
node_type = "TimeUnlock"

rel_texture_fp = row.get("Progression")
if isinstance(rel_texture_fp, str):
texture_fp = os.path.join(f"/Game/GUI/Textures/Customization/Advancements/{faction_dir}/",
rel_texture_fp.lstrip("/\\"))
basename = os.path.splitext(os.path.basename(texture_fp))[0]
texture_fp = os.path.join(os.path.dirname(texture_fp), f"{basename}.{basename}").replace("\\", "/")
else:
texture_fp = ""

new_row = make_ecr_skill_tree_skill_row(item_name, row.get("Name"), 0, row.get("Rank"),
row.get("Dependency"), row.get("ItemReward"), node_type, texture_fp)
new_data.append(new_row)

df = pd.DataFrame(data=new_data)
df.to_csv(out_csv, index=False)


if __name__ == '__main__':
in_csv = "../data/ec/advancements/csm.csv"
out_csv = "../data/ecr/advancements/csm.csv"
faction_dir = "CSM"
convert_csv_to_ingame_csv(in_csv, out_csv, faction_dir)
134 changes: 134 additions & 0 deletions Script/Python/ItemMigrationEC/parsing/skill_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import os
import sys
import json
import pandas as pd


def export_worker_dependencies(obj, dic, dic2):
if isinstance(obj, dict):
obj.pop("$type", None)
l = obj.values()
else:
l = obj

for value in l:
if value == "ECSkillLink":
dic[obj["Value"][1]["Value"]] = obj["Value"][0]["Value"]
elif value == "ECSkillAssetEntry":
dic2[obj["Value"][2]["Value"]] = f'{obj["Value"][1]["Value"][0].get("X")},{obj["Value"][1]["Value"][0].get("Y")}'
elif isinstance(value, dict) or isinstance(value, list):
export_worker_dependencies(value, dic, dic2)


# If obj contains lists or dicts, it will call itself on them
# Will purge type lines so that it is less messy
def export_worker(obj, dic, imports):
if isinstance(obj, dict):
obj.pop("$type", None)
l = obj.values()

if "bIsAsset" in obj.keys():
if obj["bIsAsset"] == True:
dic["name"] = obj["ObjectName"]

if "Name" in obj.keys():
if obj["Name"] == "Name":
dic["displayName"] = obj["CultureInvariantString"]
elif obj["Name"] == "ItemReward":
dic["itemReward"] += imports[abs(obj["Value"][0]["Value"]) - 1]["ObjectName"]

else:
l = obj

for value in l:
if value == "Amount":
dic["progressionPointsCost"] = obj["Value"]

elif value == "Rank":
dic["rank"] = obj["Value"]

elif isinstance(value, dict) or isinstance(value, list):
export_worker(value, dic, imports)


def get_dependency_map(input_json):
with open(input_json, "r") as f:
data = json.load(f)

link_dep_map = {}
link_pos_map = {}
node_map = {}
dep_map = {}
pos_map = {}

imports = data["Imports"]
i = -1
for e in imports:
node_map[i] = e["ObjectName"]
i -= 1

exports = data["Exports"]
export_worker_dependencies(exports, link_dep_map, link_pos_map)

for k, v in link_dep_map.items():
dep_map[node_map[k]] = node_map[v]

for k, v in link_pos_map.items():
pos_map[node_map[k]] = v

return dep_map, pos_map


def export_items(input_dir, output_csv, dep_map, pos_map, ignored_files):
items = []

for root, dirs, files in os.walk(input_dir):
for file in files:
if file in ignored_files:
continue

item = {}

with open((os.path.join(root, file)), 'r') as f:
try:
item["name"] = ""
item["displayName"] = ""
item["progressionPointsCost"] = 0
item["rank"] = 0
item["dependency"] = ""
item["itemReward"] = ""

data = json.load(f)
exports = data["Exports"]
export_worker(exports, item, data["Imports"])

if item["name"] in dep_map.keys():
item["dependency"] = dep_map[item["name"]]

if item["name"] in pos_map.keys():
item["ui_position"] = pos_map[item["name"]]

except Exception as e:
print(os.path.join(root, file))
print(e)

items.append(item)

df = pd.DataFrame(data=items)
df = df.rename(
{"name": "Progression", "displayName": "Name", "progressionPointsCost": "ProgressionPointsCost", "rank": "Rank",
"dependency": "Dependency", "itemReward": "ItemReward"}, axis=1)
print(df)
df.to_csv(output_csv, index=False)


if __name__ == '__main__':
input_dir = "../data/ec_raw/progression_trees/csm/"
tree_json = "ChaosAdvancements.json"
ignored_files = ["SpaceMarineAdvancements_NEW.json", "SpaceWolfAdvancements4.json", "ChaosAdvancements.json"]
output_csv = "../data/ec/advancements/csm.csv"

input_json = os.path.join(input_dir, tree_json)
dep_map, pos_map = get_dependency_map(input_json)
print(pos_map)
export_items(input_dir, output_csv, dep_map, pos_map, ignored_files)
4 changes: 2 additions & 2 deletions Script/Python/ItemMigrationEC/parsing/uasset_to_json.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import subprocess

uasset_dir = "C:/Program Files (x86)\Steam/steamapps/common/Warhammer 40,000 - Eternal Crusade/extract/unpacked/EternalCrusade/Content/DataAssets/Characters/"
output_dir = "../data/ec_raw/data_assets_chars/csm/"
uasset_dir = "C:/Program Files (x86)\Steam/steamapps/common/Warhammer 40,000 - Eternal Crusade/extract/unpacked/EternalCrusade/Content/ProgressionTrees/ChaosAdvancements/"
output_dir = "../data/ec_raw/progression_trees/csm/"
test_mode = False

for root, dirs, files in os.walk(uasset_dir, topdown=False):
Expand Down
16 changes: 16 additions & 0 deletions Script/Python/ItemMigrationEC/visualizing/convert_tga.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from PIL import Image
import os


def convert_tga_to_png(directory):
for filename in os.listdir(directory):
if filename.endswith(".tga"):
img_path = os.path.join(directory, filename)
img = Image.open(img_path)
png_path = os.path.join(directory, filename.replace(".tga", ".png"))
img.save(png_path, "PNG")
print(f"Converted {filename} to {png_path}")


# Example usage
convert_tga_to_png("C:/Users/JediKnight/Downloads/ChaosAdvancementsIcons/ChaosAdvancements/")
16 changes: 14 additions & 2 deletions Script/Python/ItemMigrationEC/visualizing/draw_advancment_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def draw_graph(graph_dict, text_dict, output_fp):

graph = {}
text_dict = {}
df = pd.read_csv("./data/ec/advancements/lsm.csv")
df = pd.read_csv("../data/ec/advancements/csm.csv")
df = df.fillna("")

for i, row in df.iterrows():
Expand All @@ -153,5 +153,17 @@ def draw_graph(graph_dict, text_dict, output_fp):

text_dict[my_node] = f"{my_node} ({row.get('Rank', 1)})<br>Name: {row.get('Name')}<br>Item: {row.get('ItemReward')}"

print(graph)
graph_new = graph.copy()
c = 0
for g1 in graph.keys():
does_meet = False
for g2, g2_items_l in graph.items():
if g1 in g2_items_l:
does_meet = True
if not does_meet:
graph_new[f"Start_{c}"] = [g1]
c += 1
print(graph_new)
# Draw the graph and save it to an HTML file
draw_graph(graph, text_dict, "./data/ecr/advancements/lsm_graph.html")
draw_graph(graph_new, text_dict, "../data/ecr/advancements/csm_graph.html")
Loading

0 comments on commit 5ca5a8d

Please sign in to comment.