diff --git a/assets/converters.py b/assets/converters.py index 5ee1245..da2c3f1 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -7,7 +7,8 @@ import fxconv from tiled import * VERBOSE = 1 -SIGN_TYPES = ["INFO", "SGN"] +SIGN_TYPES = ["SGN", "INFO"] +FACES = ["MALE", "FEMALE", "MILKMAN", "POLICE"] def convert(input, output, params, target): if params["custom-type"] == "tmx": @@ -49,6 +50,17 @@ def convert_map(input, output, params, target): + f" Error message: {e}\n") sys.exit(1) + # Get the map position + try: + if VERBOSE: print("INFO: Getting the map position") + map_x = int(input_map.get_property("mapX")) + map_y = int(input_map.get_property("mapY")) + if VERBOSE: print(f"INFO: Map position: ({map_x}, {map_y}).") + except Exception as e: + sys.stderr.write(f"ERROR: Failed to get the map position.\n" + + f" Error message: {e}\n") + sys.exit(1) + # Get informations about dialogs try: if VERBOSE: print("INFO: Getting informations about dialogs") @@ -148,9 +160,10 @@ def convert_map(input, output, params, target): raise Exception("Path required but not found!") data = { "position": object.get_data(), - "needAction": object.get_property("needAction"), - "dialogID": object.get_property("dialogID"), - #"face": object.get_property("face"), + "name": object.name, + "needAction": int(object.get_property("needAction")), + "dialogID": int(object.get_property("dialogID")), + "face": FACES.index(object.get_property("face")), "path": path } npcs[object.id] = data @@ -158,8 +171,11 @@ def convert_map(input, output, params, target): for object in ed_objgroup.objects: if object.get_data_type() == "point" and object.type in SIGN_TYPES: data = { - "needAction": object.get_property("needAction"), - "dialogID": object.get_property("dialogID") + "position": object.get_data(), + "name": object.name, + "needAction": int(object.get_property("needAction")), + "dialogID": int(object.get_property("dialogID")), + "icon": SIGN_TYPES.index(object.type) } signs[object.id] = data except Exception as e: @@ -187,8 +203,17 @@ def convert_map(input, output, params, target): map_struct += fxconv.u32(0) # TODO: NPC support in-game map_struct += fxconv.ptr(bytes()) # Load signs - map_struct += fxconv.u32(0) # TODO: Sign support in-game - map_struct += fxconv.ptr(bytes()) + map_struct += fxconv.u32(len(signs)) # TODO: Sign support in-game + sign_struct = fxconv.Structure() + for i in signs.values(): + sign_struct += fxconv.u32(i["position"][0]) + sign_struct += fxconv.u32(i["position"][1]) + sign_struct += fxconv.u32(i["icon"]) + sign_struct += fxconv.string(i["name"]) + sign_struct += fxconv.u32(i["dialogID"]) + sign_struct += fxconv.u32(i["needAction"]) + map_struct += fxconv.ptr(sign_struct) + # Load portals map_struct += fxconv.u32(0) # TODO: Portal support in-game map_struct += fxconv.ptr(bytes()) map_struct += fxconv.u32(dialog_num) @@ -227,7 +252,7 @@ def convert_dialog(input, output, params, target): dialog_struct += fxconv.u32(dialog_id) dialog_struct += fxconv.string(i["dialog"]) dialog_struct += fxconv.u32(i["isQuestion"]) - dialog_struct += fxconv.string(i["choice"]) + dialog_struct += fxconv.string(i["choice"].replace('$', '\0')) dialog_struct += fxconv.string(i["conclusion1"]) dialog_struct += fxconv.u32(i["next1"]) dialog_struct += fxconv.string(i["conclusion2"]) diff --git a/assets/level0.tmx b/assets/level0.tmx index 108691e..f61d568 100644 --- a/assets/level0.tmx +++ b/assets/level0.tmx @@ -5,6 +5,8 @@ + + @@ -117,6 +119,7 @@ + @@ -126,6 +129,7 @@ + @@ -135,6 +139,7 @@ + diff --git a/assets/level1.tmx b/assets/level1.tmx index dabb013..7412c7c 100644 --- a/assets/level1.tmx +++ b/assets/level1.tmx @@ -2,6 +2,8 @@ + + diff --git a/assets/level2.tmx b/assets/level2.tmx index 9c97e09..4e5e341 100644 --- a/assets/level2.tmx +++ b/assets/level2.tmx @@ -2,6 +2,8 @@ + + diff --git a/assets/level3.tmx b/assets/level3.tmx index 7df4045..2a6a92e 100644 --- a/assets/level3.tmx +++ b/assets/level3.tmx @@ -2,6 +2,8 @@ + + diff --git a/assets/level4.tmx b/assets/level4.tmx index 8054046..3b84d5a 100644 --- a/assets/level4.tmx +++ b/assets/level4.tmx @@ -2,6 +2,8 @@ + + @@ -100,7 +102,7 @@ - + diff --git a/src/map.c b/src/map.c index 4b08e75..89dce2f 100644 --- a/src/map.c +++ b/src/map.c @@ -224,8 +224,3 @@ short int map_get_walkable(Game *game, int x, int y) { ? map_level->walkable[y * map_level->w + x] : MAP_OUTSIDE; } - -/* return the pointer to the map containing the given position */ -Map *map_get_for_coordinates(Game *game, int x, int y) { - return game->map_level; -} diff --git a/src/map.h b/src/map.h index 70a4b0e..c49d0af 100644 --- a/src/map.h +++ b/src/map.h @@ -50,13 +50,4 @@ short int map_get_tile(Game *game, int x, int y, int l); */ short int map_get_walkable(Game *game, int x, int y); -/* map_get_for_coordinates() - * - * return the pointer to the map containing the given position. - * game: The game struct. - * x: The coordinates to look at. - * y: The coordinates to look at. - */ -Map *map_get_for_coordinates(Game *game, int x, int y); - #endif