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.
VERBOSE = 1
# The valid path objects.
PATH_TYPES = ["polyline", "polygon"]
# The sign types, used to find the sign icon.
SIGN_TYPES = ["SGN", "INFO"]
# The NPC faces, used to find the face id.
@ -70,7 +72,7 @@ def convert_map(input: str, output: str, params: dict, target):
npcs = {}
signs = {}
portals = {}
indoor = 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"
+ f" Error message: {e}\n")
sys.exit(1)
# Get the map position
try:
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"
+ f" Error message: {e}\n")
sys.exit(1)
# Get informations about dialogs
try:
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"
+ f" Error message: {e}\n")
sys.exit(1)
# Get the walkable tileset
try:
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"
+ f" Error message: {e}\n")
sys.exit(1)
# Check if this is an indoor map
try:
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:
# Show a warning
print(f"WARNING: Indoor property not found.\n")
if indoor:
# Get the indoor tileset
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"
+ f" Error message: {e}\n")
sys.exit(1)
# Get the foreground
try:
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"
+ f" Error message: {e}\n")
sys.exit(1)
# Get the walkable layer
try:
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")
# Get the paths the NPCs take.
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()
# Get the NPCs
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)
else: ypath += fxconv.u16(n)
x = not x
npc_struct += fxconv.ptr(xpath)
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"
+ f" Error message: {e}\n")
sys.exit(1)
# Create the dialog struct
dialog_struct = fxconv.Structure()
try:

View file

@ -1,5 +1,5 @@
<?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>
<property name="dialogFile" type="file" value="interior1_0_dialogs.json"/>
<property name="indoor" type="int" value="1"/>
@ -76,5 +76,18 @@
<property name="destPortal" value="taverne"/>
</properties>
</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>
</map>

View file

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

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