mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2025-05-28 14:35:18 +02:00
Started adding NPCs back to the game
This commit is contained in:
parent
da63b8ce06
commit
dfb61f18fe
3 changed files with 49 additions and 9 deletions
|
@ -152,17 +152,25 @@ def convert_map(input, output, params, target):
|
||||||
# Get the NPCs
|
# Get the NPCs
|
||||||
for object in ed_objgroup.objects:
|
for object in ed_objgroup.objects:
|
||||||
if object.get_data_type() == "point" and object.type == "NPC":
|
if object.get_data_type() == "point" and object.type == "NPC":
|
||||||
path = None
|
path = object.get_data()
|
||||||
if int(object.get_property("hasPath")):
|
if int(object.get_property("hasPath")):
|
||||||
if object.get_property("path") in npc_paths:
|
if object.get_property("path") in npc_paths:
|
||||||
path = npc_paths[object.get_property("path")]
|
path = npc_paths[object.get_property("path")]
|
||||||
else:
|
else:
|
||||||
raise Exception("Path required but not found!")
|
raise Exception("Path required but not found!")
|
||||||
|
dialog_id = 0
|
||||||
|
has_dialog = 0
|
||||||
|
try:
|
||||||
|
dialog_id = int(object.get_property("dialogID"))
|
||||||
|
has_dialog = 1
|
||||||
|
except:
|
||||||
|
pass
|
||||||
data = {
|
data = {
|
||||||
"position": object.get_data(),
|
"position": object.get_data(),
|
||||||
"name": object.name,
|
"name": object.name,
|
||||||
"needAction": int(object.get_property("needAction")),
|
"needAction": int(object.get_property("needAction")),
|
||||||
"dialogID": int(object.get_property("dialogID")),
|
"dialogID": dialog_id,
|
||||||
|
"hasDialog": has_dialog,
|
||||||
"face": FACES.index(object.get_property("face")),
|
"face": FACES.index(object.get_property("face")),
|
||||||
"path": path
|
"path": path
|
||||||
}
|
}
|
||||||
|
@ -200,10 +208,41 @@ def convert_map(input, output, params, target):
|
||||||
map_struct += fxconv.ptr(walkable_data)
|
map_struct += fxconv.ptr(walkable_data)
|
||||||
|
|
||||||
# Load NPCs
|
# Load NPCs
|
||||||
map_struct += fxconv.u32(0) # TODO: NPC support in-game
|
map_struct += fxconv.u32(len(npcs))
|
||||||
map_struct += fxconv.ptr(bytes())
|
npc_struct = fxconv.Structure()
|
||||||
|
for i in npcs.values():
|
||||||
|
npc_struct += fxconv.u32(i["path"][0])
|
||||||
|
npc_struct += fxconv.u32(i["path"][1])
|
||||||
|
npc_struct += fxconv.u32(i["position"][0])
|
||||||
|
npc_struct += fxconv.u32(i["position"][1])
|
||||||
|
npc_struct += fxconv.u16(i["face"])
|
||||||
|
npc_struct += fxconv.u8(0)
|
||||||
|
npc_struct += fxconv.u8(i["hasDialog"])
|
||||||
|
npc_struct += fxconv.u32(i["dialogID"])
|
||||||
|
npc_struct += fxconv.u32(i["needAction"])
|
||||||
|
npc_struct += fxconv.string(i["name"])
|
||||||
|
npc_struct += fxconv.u32(len(i["path"]) > 2)
|
||||||
|
npc_struct += fxconv.u32(len(i["path"])//2)
|
||||||
|
npc_struct += fxconv.u32(0)
|
||||||
|
|
||||||
|
xpath = bytes()
|
||||||
|
ypath = bytes()
|
||||||
|
x = True
|
||||||
|
for n in i["path"]:
|
||||||
|
if x: xpath += fxconv.u16(n)
|
||||||
|
else: ypath += fxconv.u16(n)
|
||||||
|
x = not x
|
||||||
|
|
||||||
|
npc_struct += fxconv.ptr(xpath)
|
||||||
|
npc_struct += fxconv.ptr(ypath)
|
||||||
|
|
||||||
|
npc_struct += fxconv.u32(0) # TODO: Type
|
||||||
|
npc_struct += fxconv.u8(0) # TODO: Group
|
||||||
|
npc_struct += fxconv.u8(0) # TODO: Hostile to
|
||||||
|
npc_struct += fxconv.u16(0) # TODO: Padding (what is it ?)
|
||||||
|
map_struct += fxconv.ptr(npc_struct)
|
||||||
# Load signs
|
# Load signs
|
||||||
map_struct += fxconv.u32(len(signs)) # TODO: Sign support in-game
|
map_struct += fxconv.u32(len(signs))
|
||||||
sign_struct = fxconv.Structure()
|
sign_struct = fxconv.Structure()
|
||||||
for i in signs.values():
|
for i in signs.values():
|
||||||
sign_struct += fxconv.u32(i["position"][0])
|
sign_struct += fxconv.u32(i["position"][0])
|
||||||
|
|
|
@ -24,7 +24,7 @@ void interaction_available(Game *game) {
|
||||||
/*NPCs take priority over signs*/
|
/*NPCs take priority over signs*/
|
||||||
|
|
||||||
for(uint32_t i = 0; i < game->map_level->nbNPC; i++) {
|
for(uint32_t i = 0; i < game->map_level->nbNPC; i++) {
|
||||||
if(!game->map_level->npcs[i].has_dialogue)
|
if(!game->map_level->npcs[i].has_dialog)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* simple distance check along X and Y axis */
|
/* simple distance check along X and Y axis */
|
||||||
|
|
|
@ -72,7 +72,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* current coordinates of the NPC */
|
/* current coordinates of the NPC */
|
||||||
float curx, cury;
|
uint32_t curx; /* Initialize them at runtime */
|
||||||
|
uint32_t cury; /* Initialize them at runtime */
|
||||||
|
|
||||||
/* initial coordinates of the NPC (needed to get absolute coordinates of
|
/* initial coordinates of the NPC (needed to get absolute coordinates of
|
||||||
* path) */
|
* path) */
|
||||||
|
@ -83,7 +84,7 @@ typedef struct {
|
||||||
|
|
||||||
uint8_t paused;
|
uint8_t paused;
|
||||||
|
|
||||||
uint8_t has_dialogue;
|
uint8_t has_dialog;
|
||||||
/* the ID of the first element of the dialog */
|
/* the ID of the first element of the dialog */
|
||||||
/* (to be aligned with "dialogs.json" IDs)*/
|
/* (to be aligned with "dialogs.json" IDs)*/
|
||||||
uint32_t dialogID;
|
uint32_t dialogID;
|
||||||
|
@ -99,7 +100,7 @@ typedef struct {
|
||||||
int16_t *xpath;
|
int16_t *xpath;
|
||||||
int16_t *ypath;
|
int16_t *ypath;
|
||||||
|
|
||||||
int type;
|
int type : 32;
|
||||||
|
|
||||||
uint8_t current_group;
|
uint8_t current_group;
|
||||||
uint8_t hostile_to_group;
|
uint8_t hostile_to_group;
|
||||||
|
|
Loading…
Add table
Reference in a new issue