summaryrefslogtreecommitdiff
path: root/extractor
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-24 00:36:06 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-24 00:36:06 +0100
commit6e2deea3d1b2fb4d79dac02a0d4310936c7f317c (patch)
tree05590a7d9f7cecde037aad7a5487ff2c62176932 /extractor
parent7b3f386449aeab124d84d2aff4c273e646e68763 (diff)
next commit
Diffstat (limited to 'extractor')
-rw-r--r--extractor/grf.gd39
-rw-r--r--extractor/rsw_format.gd97
2 files changed, 136 insertions, 0 deletions
diff --git a/extractor/grf.gd b/extractor/grf.gd
index 08f72ee..e2a3c82 100644
--- a/extractor/grf.gd
+++ b/extractor/grf.gd
@@ -219,14 +219,19 @@ func convert(destination: String = "res://client_data"):
#DirAccess.make_dir_recursive_absolute(base_file_directory_path)
+
+ # Sprite.spr and Action.act
+
var player_head_path_part = "¸Ó¸®Åë"
var player_body_path_part = "¸öÅë"
if file_path.ends_with(".spr") and file_path.contains(player_head_path_part):
+ continue
var sprite = SpriteFormat.from_bytes(file_entry.get_contents(file_access))
sprite.save_to_file(base_file_directory_path)
elif file_path.ends_with(".act") and file_path.contains(player_head_path_part):
+ continue
if not FileAccess.file_exists("%s/000.png.import" % base_file_directory_path):
continue
@@ -409,6 +414,40 @@ func convert(destination: String = "res://client_data"):
# TODO: doesn't work if png is not imported via editor focus => run game twice
ResourceSaver.save(scene, "%s/actions.tscn" % base_file_directory_path)
+
+
+ # Map.rsw and .gnd and .gat
+
+ if file_path.ends_with(".rsw") and file_path.contains("pay_dun"):
+ var rsw = RSWFormat.from_bytes(ByteStream.from_bytes(file_entry.get_contents(file_access)))
+
+ var gnd_file_path = "res://client_data/data/%s" % rsw.gnd_file
+ var gnd = GNDFormat.from_bytes(ByteStream.from_bytes(FileAccess.get_file_as_bytes(gnd_file_path)))
+
+ var gat_file_path = "res://client_data/data/%s" % rsw.gat_file
+ var gat = GATFormat.from_bytes(ByteStream.from_bytes(FileAccess.get_file_as_bytes(gat_file_path)))
+
+ var scene := PackedScene.new()
+ var scene_root := Node3D.new()
+ scene_root.name = file_name
+
+ for resource in rsw.map_resources:
+ if resource is RSWFormat.SpatialAudioSource:
+ var audio_file_path := "res://client_data/data/wav/%s" % resource.audio_file
+ if not FileAccess.file_exists(audio_file_path):
+ continue
+
+ var audio = AudioStreamPlayer3D.new()
+ audio.stream = load(audio_file_path)
+ audio.name = resource.audio_file
+ audio.position = resource.get_position()
+ audio.volume_linear = resource.volume_gain
+ audio.max_distance = resource.audio_range
+ scene_root.add_child(audio, true)
+ audio.owner = scene_root
+
+ scene.pack(scene_root)
+ ResourceSaver.save(scene, "%s/%s/%s.tscn" % [destination, base_directory_path, file_name])
static func decode_string(bytes: PackedByteArray):
diff --git a/extractor/rsw_format.gd b/extractor/rsw_format.gd
index 18874e2..ea1bf26 100644
--- a/extractor/rsw_format.gd
+++ b/extractor/rsw_format.gd
@@ -231,6 +231,13 @@ enum ParticlePresetEffect {
TunaParty = 1097,
}
+enum QuadTreeQuadrant {
+ BottomLeft = 0,
+ BottomRight = 1,
+ TopLeft = 2,
+ TopRight = 3,
+}
+
class Animated3DModel extends MapResource:
## Byte Type: u8 [br]
@@ -517,3 +524,93 @@ class ParticleEffectEmitter extends MapResource:
resource.launch_parameter_d = bytes.decode_float()
return resource
+
+
+class QuadTree:
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## coordinate of the corner at the lowest altitude
+ var bottom_x: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4
+ var bottom_y: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4
+ var bottom_z: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## coordinate of the corner at the highest altitude
+ var top_x: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4
+ var top_y: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4
+ var top_z: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## width of the bounding box (when interpreted as a cuboid)
+ var diameter_x: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## height of the bounding box (when interpreted as a cuboid)
+ var diameter_y: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## depth of the bounding box (when interpreted as a cuboid)
+ var diameter_z: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## coordinate of the point in the exact center of the box
+ var center_x: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4
+ var center_y: float
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4
+ var center_z: float
+
+ ## Length: 4 [br]
+ ## null if leaf node at sub-tree level 5 [br]
+ ## indexes are [enum QuadTreeQuadrant]
+ var quadrants: Array[QuadTree]
+
+
+ func get_bottom() -> Vector3:
+ return Vector3(bottom_x, bottom_y, bottom_z)
+
+
+ func get_top() -> Vector3:
+ return Vector3(top_x, top_y, top_z)
+
+
+ func get_diameter() -> Vector3:
+ return Vector3(diameter_x, diameter_y, diameter_z)
+
+
+ func get_center() -> Vector3:
+ return Vector3(center_x, center_y, center_z)
+
+
+ static func from_bytes(bytes: ByteStream) -> QuadTree:
+ var tree = QuadTree.new()
+
+ tree.bottom_x = bytes.decode_float()
+
+ return tree
+
+
+ static func from_bytes_recursive(bytes: ByteStream, tree: QuadTree, depth: int):
+ if depth == 5 or tree.quadrants.size() == 4:
+ pass