Added a NPC to the taverne. Polygons are now valid paths.

This commit is contained in:
mibi88 2024-08-01 13:27:16 +02:00
parent e581fd31b1
commit 3170f25e91
4 changed files with 34 additions and 19 deletions

View file

@ -28,6 +28,8 @@ from tinytiled import *
# If the output of the converter should be verbose. # If the output of the converter should be verbose.
VERBOSE = 1 VERBOSE = 1
# The valid path objects.
PATH_TYPES = ["polyline", "polygon"]
# The sign types, used to find the sign icon. # The sign types, used to find the sign icon.
SIGN_TYPES = ["SGN", "INFO"] SIGN_TYPES = ["SGN", "INFO"]
# The NPC faces, used to find the face id. # The NPC faces, used to find the face id.
@ -70,7 +72,7 @@ def convert_map(input: str, output: str, params: dict, target):
npcs = {} npcs = {}
signs = {} signs = {}
portals = {} portals = {}
indoor = 0 indoor = 0
name = os.path.splitext(os.path.basename(input))[0] name = os.path.splitext(os.path.basename(input))[0]
@ -87,7 +89,7 @@ def convert_map(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed to get the dialog file.\n" sys.stderr.write(f"ERROR: Failed to get the dialog file.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Get the map position # Get the map position
try: try:
if VERBOSE: print("INFO: Getting the map position") if VERBOSE: print("INFO: Getting the map position")
@ -99,7 +101,7 @@ def convert_map(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed to get the map position.\n" sys.stderr.write(f"ERROR: Failed to get the map position.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Get informations about dialogs # Get informations about dialogs
try: try:
if VERBOSE: print("INFO: Getting informations about dialogs") if VERBOSE: print("INFO: Getting informations about dialogs")
@ -123,7 +125,7 @@ def convert_map(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed to get the outdoor tileset.\n" sys.stderr.write(f"ERROR: Failed to get the outdoor tileset.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Get the walkable tileset # Get the walkable tileset
try: try:
if VERBOSE: print("INFO: Getting the walkable tileset") if VERBOSE: print("INFO: Getting the walkable tileset")
@ -133,7 +135,7 @@ def convert_map(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed to get the walkable tileset.\n" sys.stderr.write(f"ERROR: Failed to get the walkable tileset.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Check if this is an indoor map # Check if this is an indoor map
try: try:
if VERBOSE: print("INFO: Checking if it is an indoor map") if VERBOSE: print("INFO: Checking if it is an indoor map")
@ -141,7 +143,7 @@ def convert_map(input: str, output: str, params: dict, target):
except Exception as e: except Exception as e:
# Show a warning # Show a warning
print(f"WARNING: Indoor property not found.\n") print(f"WARNING: Indoor property not found.\n")
if indoor: if indoor:
# Get the indoor tileset # Get the indoor tileset
try: try:
@ -176,7 +178,7 @@ def convert_map(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed to get the background layer.\n" sys.stderr.write(f"ERROR: Failed to get the background layer.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Get the foreground # Get the foreground
try: try:
if VERBOSE: print("INFO: Getting the foreground layer") if VERBOSE: print("INFO: Getting the foreground layer")
@ -195,7 +197,7 @@ def convert_map(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed to get the foreground layer.\n" sys.stderr.write(f"ERROR: Failed to get the foreground layer.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Get the walkable layer # Get the walkable layer
try: try:
if VERBOSE: print("INFO: Getting the walkable layer") if VERBOSE: print("INFO: Getting the walkable layer")
@ -218,7 +220,7 @@ def convert_map(input: str, output: str, params: dict, target):
ed_objgroup = input_map.get_objectgroup_by_name("ExtraData") ed_objgroup = input_map.get_objectgroup_by_name("ExtraData")
# Get the paths the NPCs take. # Get the paths the NPCs take.
for object in ed_objgroup.objects: for object in ed_objgroup.objects:
if object.get_data_type() == "polyline": if object.get_data_type() in PATH_TYPES:
npc_paths[object.id] = object.get_data() npc_paths[object.id] = object.get_data()
# Get the NPCs # Get the NPCs
for object in ed_objgroup.objects: for object in ed_objgroup.objects:
@ -323,7 +325,7 @@ def convert_map(input: str, output: str, params: dict, target):
if x: xpath += fxconv.u16(n) if x: xpath += fxconv.u16(n)
else: ypath += fxconv.u16(n) else: ypath += fxconv.u16(n)
x = not x x = not x
npc_struct += fxconv.ptr(xpath) npc_struct += fxconv.ptr(xpath)
npc_struct += fxconv.ptr(ypath) npc_struct += fxconv.ptr(ypath)
@ -401,7 +403,7 @@ def convert_dialog(input: str, output: str, params: dict, target):
sys.stderr.write(f"ERROR: Failed parse json.\n" sys.stderr.write(f"ERROR: Failed parse json.\n"
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) sys.exit(1)
# Create the dialog struct # Create the dialog struct
dialog_struct = fxconv.Structure() dialog_struct = fxconv.Structure()
try: try:

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="24" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="3"> <map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="24" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="5">
<properties> <properties>
<property name="dialogFile" type="file" value="interior1_0_dialogs.json"/> <property name="dialogFile" type="file" value="interior1_0_dialogs.json"/>
<property name="indoor" type="int" value="1"/> <property name="indoor" type="int" value="1"/>
@ -76,5 +76,18 @@
<property name="destPortal" value="taverne"/> <property name="destPortal" value="taverne"/>
</properties> </properties>
</object> </object>
<object id="3" name="SERVEUR" type="NPC" x="109.092" y="88.3408">
<properties>
<property name="dialogID" type="int" value="0"/>
<property name="face" value="MALE"/>
<property name="hasPath" type="int" value="1"/>
<property name="needAction" type="int" value="1"/>
<property name="path" type="object" value="4"/>
</properties>
<point/>
</object>
<object id="4" name="Chemin serveur" type="TRJ" x="108.796" y="87.7479">
<polygon points="0,0 43.2811,-4.74313 46.2455,19.5654 46.542,-34.6841 50.3958,-4.74313 -97.8271,-3.85379 -97.5306,28.1623 -61.0678,27.8659 -53.0638,27.8659 -61.3642,23.4192 -58.3998,-2.66801 -48.6171,-7.41114 -50.0993,-28.1623 8.30048,-28.7552 7.70759,-52.7673 -69.6647,-52.4709 8.30048,-53.0638 9.48626,-26.6801"/>
</object>
</objectgroup> </objectgroup>
</map> </map>

View file

@ -1,13 +1,13 @@
{ "dialogs":[ { "dialogs":[
{ "ID":0, { "ID":0,
"dialog":"_", "dialog":"Bonjour, qu'est ce que je vous sers ?",
"isQuestion":0, "isQuestion":1,
"choice":"_", "choice":"Une pinte de biere$Rien",
"conclusion1":"_", "conclusion1":"Voici pour vous.`$life+10`",
"next1":-1, "next1":-1,
"conclusion2":"_", "conclusion2":"Bah qu'est ce que vous faites ici alors !",
"next2":-1, "next2":-1,
"nextOther":1 "nextOther":-1
} }
] ]
} }

@ -1 +1 @@
Subproject commit b084ecda91a2352a72a5d1a61b37e0009228ee40 Subproject commit b88240b6f8cb3ccace66ae7ea4801b5acefc91ff