Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Cyberpunk-Helper-Scripts
scripts to help automate troubleshooting and other tasks for modding cyberpunk 2077.

scripts to help automate troubleshooting and other tasks for modding cyberpunk 2077.

FindAllErrors.bat - updated or version 2.12a
USAGE:
Simply place the file in your install directory or drag and drop your Cyberpunk 2077 folder on top of the .bat wherever it may be. The script will dig through the folder
USAGE:
Simply place the file in your install directory or drag and drop your Cyberpunk 2077 folder on top of the .bat wherever
it may be. The script will dig through the folder
for logs, extract any error messages and print them to a new file called FilteredLogs.txt for easy troubleshooting.
65 changes: 37 additions & 28 deletions export_phys.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
# by The Magnificent Doctor Presto August 4 2023
# /$$ https://github.com/DoctorPresto/Cyberpunk-Helper-Scripts /$$ /$$$$$$
# | $$ | $$ /$$__ $$
# /$$$$$$| $$$$$$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$ \__/$$$$$$ /$$$$$$
# /$$__ $| $$__ $| $$ | $$/$$_____/ /$$__ $| $$ /$$//$$__ $$/$$__ $$/$$__ $|_ $$_/ | $$$$ /$$__ $$/$$__ $$
# | $$ \ $| $$ \ $| $$ | $| $$$$$$ | $$$$$$$$\ $$$$/| $$ \ $| $$ \ $| $$ \__/ | $$ | $$_/ | $$ \ $| $$ \__/
# | $$ | $| $$ | $| $$ | $$\____ $$ | $$_____/ >$$ $$| $$ | $| $$ | $| $$ | $$ /$$ | $$ | $$ | $| $$
# | $$$$$$$| $$ | $| $$$$$$$/$$$$$$$/ | $$$$$$$/$$/\ $| $$$$$$$| $$$$$$| $$ | $$$$/ | $$ | $$$$$$| $$
# | $$____/|__/ |__/\____ $|_______/ \_______|__/ \__| $$____/ \______/|__/ \___/ |__/ \______/|__/
# | $$ /$$ | $$ /$$$$$$$ /$$ | $$ /$$
# | $$ | $$$$$$/ | $$__ $| $$ | $$ | $$
# |__/ \______/ | $$ \ $| $$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$
# | $$$$$$$| $$/$$__ $| $$__ $$/$$__ $$/$$__ $$/$$__ $$
# | $$__ $| $| $$$$$$$| $$ \ $| $$ | $| $$$$$$$| $$ \__/
# | $$ \ $| $| $$_____| $$ | $| $$ | $| $$_____| $$
# | $$$$$$$| $| $$$$$$| $$ | $| $$$$$$| $$$$$$| $$
# |_______/|__/\_______|__/ |__/\_______/\_______|__/
import json
import bpy
import os
import bmesh

import bpy
import mathutils

### Just enter the path tio your original .json file here and the script will export the changes you've made in blender to a copy of the original json in
### that will be saved into same directory as the original with a new_ prefix. All you need to do is right click on this file in wolvenkit and convert from json back to .phys
# by The Magnificent Doctor Presto August 4 2023
# /$$ https://github.com/DoctorPresto/Cyberpunk-Helper-Scripts /$$ /$$$$$$
# | $$ | $$ /$$__ $$
# /$$$$$$| $$$$$$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$ \__/$$$$$$ /$$$$$$
# /$$__ $| $$__ $| $$ | $$/$$_____/ /$$__ $| $$ /$$//$$__ $$/$$__ $$/$$__ $|_ $$_/ | $$$$ /$$__ $$/$$__ $$
# | $$ \ $| $$ \ $| $$ | $| $$$$$$ | $$$$$$$$\ $$$$/| $$ \ $| $$ \ $| $$ \__/ | $$ | $$_/ | $$ \ $| $$ \__/
# | $$ | $| $$ | $| $$ | $$\____ $$ | $$_____/ >$$ $$| $$ | $| $$ | $| $$ | $$ /$$ | $$ | $$ | $| $$
# | $$$$$$$| $$ | $| $$$$$$$/$$$$$$$/ | $$$$$$$/$$/\ $| $$$$$$$| $$$$$$| $$ | $$$$/ | $$ | $$$$$$| $$
# | $$____/|__/ |__/\____ $|_______/ \_______|__/ \__| $$____/ \______/|__/ \___/ |__/ \______/|__/
# | $$ /$$ | $$ /$$$$$$$ /$$ | $$ /$$
# | $$ | $$$$$$/ | $$__ $| $$ | $$ | $$
# |__/ \______/ | $$ \ $| $$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$
# | $$$$$$$| $$/$$__ $| $$__ $$/$$__ $$/$$__ $$/$$__ $$
# | $$__ $| $| $$$$$$$| $$ \ $| $$ | $| $$$$$$$| $$ \__/
# | $$ \ $| $| $$_____| $$ | $| $$ | $| $$_____| $$
# | $$$$$$$| $| $$$$$$| $$ | $| $$$$$$| $$$$$$| $$
# |_______/|__/\_______|__/ |__/\_______/\_______|__/


### Just enter the path tio your original .json file here and the script will export the changes you've made in blender to a copy of the original json in
### that will be saved into same directory as the original with a new_ prefix. All you need to do is right click on this file in wolvenkit and convert from json back to .phys

physJsonPath = "the\\full\\path\\to\\original\\json" # make sure to use \\ in your path
physJsonPath = 'the\\full\\path\\to\\original\\json' # make sure to use \\ in your path

phys = open(physJsonPath)
data = json.load(phys)
Expand All @@ -50,17 +52,22 @@
i['Data']['localToBody']['orientation']['k'] = obj.rotation_quaternion.y
i['Data']['localToBody']['orientation']['r'] = obj.rotation_quaternion.w

if colliderType == "physicsColliderConvex" or colliderType == "physicsColliderConcave":
if (
colliderType == 'physicsColliderConvex'
or colliderType == 'physicsColliderConcave'
):
mesh = obj.data
if 'vertices' in i['Data']:
for j, vert in enumerate(mesh.vertices):
i['Data']['vertices'][j]['X'] = vert.co.x
i['Data']['vertices'][j]['Y'] = vert.co.y
i['Data']['vertices'][j]['Z'] = vert.co.z

elif colliderType == "physicsColliderBox":
elif colliderType == 'physicsColliderBox':
# Calculate world-space bounding box vertices
world_bounds = [obj.matrix_world @ mathutils.Vector(coord) for coord in obj.bound_box]
world_bounds = [
obj.matrix_world @ mathutils.Vector(coord) for coord in obj.bound_box
]

# Get center of the box in world space
center = sum(world_bounds, mathutils.Vector()) / 8
Expand All @@ -74,9 +81,11 @@
i['Data']['halfExtents']['Y'] = obj.dimensions.y / 2
i['Data']['halfExtents']['Z'] = obj.dimensions.z / 2

elif colliderType == "physicsColliderCapsule":
i['Data']['radius'] = obj.dimensions.x / 2 # Divided by 2 because blender dimensions are diameter
i['Data']['height'] = obj.dimensions.z
elif colliderType == 'physicsColliderCapsule':
i['Data']['radius'] = (
obj.dimensions.x / 2
) # Divided by 2 because blender dimensions are diameter
i['Data']['height'] = obj.dimensions.z

with open(output, 'w') as f:
json.dump(data, f, indent=2)
Expand Down
43 changes: 24 additions & 19 deletions filter_anims.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,64 @@
import bpy
import os
import json

import bpy

########################## You need to fill these out ######################################################

# you need to edit this so that it points to the json you want to filter, paths need two slashes \\ not \
file_to_search = "path\\to\\your\\anims.json"
file_to_search = 'path\\to\\your\\anims.json'

## set this to True if you have imported the anims file to blender and also want it to delete all the extra nla strips
delete_anims = False
delete_anims = False

# List of anims to search for, seperated by a comma, individual lines is optional but easier to read
names_to_search = [
"anim__1",
"anim__2",

'anim__1',
'anim__2',
]

######################### you don't need to touch any of this ########################################################

# we're going to use the path of the original json to set the output path, this gets the path to the directory
# we're going to make the new file in
# we're going to use the path of the original json to set the output path, this gets the path to the directory
# we're going to make the new file in
dir_path, file_name = os.path.split(file_to_search)

# lelts get the name of the anims.json
file_name_without_extension, file_extension = os.path.splitext(file_name)

# set the new filename to match the original but with filtered_ in front
new_file_name = "filtered_" + file_name_without_extension + file_extension
# set the new filename to match the original but with filtered_ in front
new_file_name = 'filtered_' + file_name_without_extension + file_extension

# tell the script to make the new file in the directory of the original
# tell the script to make the new file in the directory of the original
output_path = os.path.join(dir_path, new_file_name)

with open(file_to_search, "r") as json_file:
with open(file_to_search, 'r') as json_file:
data = json.load(json_file)

# Create a copy of the original JSON data
output_data = data.copy()

# Create a new animations array that only contains the animations we're searching for
output_data["Data"]["RootChunk"]["animations"] = [
animation for animation in data["Data"]["RootChunk"]["animations"] if
animation["Data"]["animation"]["Data"]["name"]["$value"] in names_to_search
output_data['Data']['RootChunk']['animations'] = [
animation
for animation in data['Data']['RootChunk']['animations']
if animation['Data']['animation']['Data']['name']['$value'] in names_to_search
]

# Write the modified JSON data to the output file
with open(output_path, "w") as output_file:
with open(output_path, 'w') as output_file:
json.dump(output_data, output_file, indent=4)

# If the delete_anims bool is set to True, delete any NLA strips which have matching names to the ones we searched
if delete_anims:
for obj in bpy.context.scene.objects:
if obj.type == 'ARMATURE' and obj.animation_data and obj.animation_data.nla_tracks:
if (
obj.type == 'ARMATURE'
and obj.animation_data
and obj.animation_data.nla_tracks
):
for strip in obj.animation_data.nla_tracks:
if strip.name not in names_to_search:
obj.animation_data.nla_tracks.remove(strip)

print("your new anims.json has been saved to:" + output_path)
print('your new anims.json has been saved to:' + output_path)
Loading