NPC face property
|
@ -41,6 +41,9 @@ set(ASSETS_cg
|
|||
assets-cg/npc/char/npc_male.png
|
||||
assets-cg/SignAction.png
|
||||
assets-cg/npc/face/npc_male.png
|
||||
assets-cg/npc/face/npc_female.png
|
||||
assets-cg/npc/face/npc_milkman.png
|
||||
assets-cg/npc/face/npc_police.png
|
||||
assets-cg/SGN_Icon.png
|
||||
assets-cg/INFO_Icon.png
|
||||
assets-cg/player_face.png
|
||||
|
@ -64,6 +67,9 @@ set(ASSETS_fx
|
|||
assets-fx/npc/char/npc_male.png
|
||||
assets-fx/SignAction.png
|
||||
assets-fx/npc/face/npc_male.png
|
||||
assets-fx/npc/face/npc_female.png
|
||||
assets-fx/npc/face/npc_milkman.png
|
||||
assets-fx/npc/face/npc_police.png
|
||||
assets-fx/SGN_Icon.png
|
||||
assets-fx/INFO_Icon.png
|
||||
assets-fx/player_face.png
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
npc_male.png:
|
||||
type: bopti-image
|
||||
name: NPC_Icon_img
|
||||
name: npc_male
|
||||
npc_female.png:
|
||||
type: bopti-image
|
||||
name: npc_female
|
||||
npc_milkman.png:
|
||||
type: bopti-image
|
||||
name: npc_milkman
|
||||
npc_police.png:
|
||||
type: bopti-image
|
||||
name: npc_police
|
||||
|
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 555 B |
|
@ -1,3 +1,12 @@
|
|||
npc_male.png:
|
||||
type: bopti-image
|
||||
name: NPC_Icon_img
|
||||
name: npc_male
|
||||
npc_female.png:
|
||||
type: bopti-image
|
||||
name: npc_female
|
||||
npc_milkman.png:
|
||||
type: bopti-image
|
||||
name: npc_milkman
|
||||
npc_police.png:
|
||||
type: bopti-image
|
||||
name: npc_police
|
||||
|
|
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B |
|
@ -273,6 +273,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
|||
path_length = 0
|
||||
xdata = None
|
||||
ydata = None
|
||||
face_type = "MALE"
|
||||
|
||||
#we now fill all the properties of this item
|
||||
for j in i["properties"]:
|
||||
|
@ -282,9 +283,11 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
|||
elif j["name"]=="needAction": needAction = j[ "value" ]
|
||||
|
||||
else:
|
||||
#Extra properties for NPCs (path)
|
||||
#Extra properties for NPCs (path and face)
|
||||
if tpe=="NPC":
|
||||
if j["name"]=="hasPath":
|
||||
if j["name"]=="face":
|
||||
face_type = j["value"]
|
||||
elif j["name"]=="hasPath":
|
||||
pathID = None
|
||||
path = j[ "value" ]
|
||||
if path==1:
|
||||
|
@ -317,7 +320,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
|||
|
||||
if DEBUG:
|
||||
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialogID )
|
||||
print( " Type= ", tpe, " Name= ", nme )
|
||||
print( " Type= ", tpe, " Name= ", nme, "Face =", face_type)
|
||||
print( " Action?= ", needAction )
|
||||
|
||||
|
||||
|
@ -326,6 +329,7 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
|||
structData += fxconv.u32( int(y) )
|
||||
structData += fxconv.string( nme )
|
||||
structData += fxconv.string( tpe )
|
||||
structData += fxconv.string(face_type)
|
||||
structData += fxconv.u32( int(dialogID) )
|
||||
structData += fxconv.u32( int(needAction) )
|
||||
|
||||
|
@ -349,7 +353,6 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
|||
else:
|
||||
if DEBUG: print( "Skip this object" )
|
||||
|
||||
|
||||
return nbExtraData, structData
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="8" nextobjectid="14">
|
||||
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="8" nextobjectid="14">
|
||||
<editorsettings>
|
||||
<export target="level0.json" format="json"/>
|
||||
</editorsettings>
|
||||
|
@ -117,6 +117,7 @@
|
|||
<object id="12" name="PNJ3" type="NPC" x="267.25" y="125.75">
|
||||
<properties>
|
||||
<property name="dialogID" type="int" value="12"/>
|
||||
<property name="face" value="FEMALE"/>
|
||||
<property name="hasPath" type="int" value="1"/>
|
||||
<property name="needAction" type="int" value="1"/>
|
||||
<property name="path" type="object" value="13"/>
|
||||
|
@ -126,6 +127,7 @@
|
|||
<object id="2" name="PNJ2" type="NPC" x="164" y="132">
|
||||
<properties>
|
||||
<property name="dialogID" type="int" value="5"/>
|
||||
<property name="face" value="MALE"/>
|
||||
<property name="hasPath" type="int" value="0"/>
|
||||
<property name="needAction" type="int" value="1"/>
|
||||
<property name="path" type="object" value="0"/>
|
||||
|
@ -135,6 +137,7 @@
|
|||
<object id="10" name="PNJ1" type="NPC" x="252" y="164">
|
||||
<properties>
|
||||
<property name="dialogID" type="int" value="7"/>
|
||||
<property name="face" value="MILKMAN"/>
|
||||
<property name="hasPath" type="int" value="1"/>
|
||||
<property name="needAction" type="int" value="1"/>
|
||||
<property name="path" type="object" value="9"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="4">
|
||||
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="4">
|
||||
<properties>
|
||||
<property name="dialogFile" type="file" value="DialogsLvl1.json"/>
|
||||
</properties>
|
||||
|
@ -100,6 +100,7 @@
|
|||
<object id="2" name="Gardien" type="NPC" x="303.636" y="117.273">
|
||||
<properties>
|
||||
<property name="dialogID" type="int" value="1"/>
|
||||
<property name="face" value="POLICE"/>
|
||||
<property name="hasPath" type="int" value="1"/>
|
||||
<property name="needAction" type="int" value="1"/>
|
||||
<property name="path" type="object" value="3"/>
|
||||
|
|
|
@ -72,6 +72,7 @@ typedef struct {
|
|||
char *name;
|
||||
/* its class (NPC, SGN, INFO, ... )*/
|
||||
char *type;
|
||||
char *face;
|
||||
|
||||
/* the ID of the first element of the dialog */
|
||||
/* (to be aligned with "dialogs.json" IDs)*/
|
||||
|
|
|
@ -97,6 +97,7 @@ void reload_npc(Game *game)
|
|||
npcRPG[currentNPC].xpath = Data->xpath;
|
||||
npcRPG[currentNPC].ypath = Data->ypath;
|
||||
npcRPG[currentNPC].paused = false;
|
||||
npcRPG[currentNPC].face = Data->face;
|
||||
currentNPC++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ typedef struct
|
|||
|
||||
/* is the current NPC in pause (during dialog) */
|
||||
bool paused;
|
||||
|
||||
char *face;
|
||||
} NPC;
|
||||
|
||||
|
||||
|
|
66
src/player.c
|
@ -6,6 +6,28 @@
|
|||
#include "npc.h"
|
||||
#include <gint/display.h>
|
||||
|
||||
#define FACES 4
|
||||
|
||||
struct Face {
|
||||
const char *name;
|
||||
bopti_image_t *face;
|
||||
};
|
||||
|
||||
extern bopti_image_t demo_player_img;
|
||||
extern bopti_image_t npc_male;
|
||||
extern bopti_image_t npc_female;
|
||||
extern bopti_image_t npc_milkman;
|
||||
extern bopti_image_t npc_police;
|
||||
extern bopti_image_t SGN_Icon_img;
|
||||
extern bopti_image_t INFO_Icon_img;
|
||||
|
||||
const struct Face faces[FACES] = {
|
||||
{"MALE", &npc_male},
|
||||
{"FEMALE", &npc_female},
|
||||
{"MILKMAN", &npc_milkman},
|
||||
{"POLICE", &npc_police}
|
||||
};
|
||||
|
||||
const char one_px_mov[8] = {
|
||||
0, -1, /* Up */
|
||||
0, 1, /* Down */
|
||||
|
@ -83,14 +105,8 @@ void player_move(Game *game, Direction direction) {
|
|||
player->wy = game->map_level->ymin * PXSIZE + player->y;
|
||||
}
|
||||
|
||||
|
||||
extern bopti_image_t demo_player_img;
|
||||
extern bopti_image_t NPC_Icon_img;
|
||||
extern bopti_image_t SGN_Icon_img;
|
||||
extern bopti_image_t INFO_Icon_img;
|
||||
|
||||
|
||||
void player_action(Game *game) {
|
||||
register size_t i;
|
||||
/* already doing something (action IS NOT with an NPC) */
|
||||
if(game->player.isDoingAction) return;
|
||||
|
||||
|
@ -107,13 +123,24 @@ void player_action(Game *game) {
|
|||
/* we use the correct image as per the class of the item */
|
||||
|
||||
|
||||
if (strcmp("INFO", currentData->type)==0)
|
||||
if (strcmp("INFO", currentData->type)==0){
|
||||
face = &INFO_Icon_img;
|
||||
//else if (strcmp("NPC", currentData->type)==0)
|
||||
// face = &NPC_Icon_img;
|
||||
else if (strcmp("SGN", currentData->type)==0)
|
||||
}else if (strcmp("SGN", currentData->type)==0){
|
||||
face = &SGN_Icon_img;
|
||||
else face = &demo_player_img;
|
||||
}else{
|
||||
/* It's a NPC */
|
||||
/* (Mibi88) TODO: Use string hash + strcmp if the hashes match for
|
||||
* fast string comparison. */
|
||||
face = NULL;
|
||||
for(i=0;i<FACES;i++){
|
||||
struct Face current_face = faces[i];
|
||||
if(!strcmp(current_face.name, currentData->face)){
|
||||
face = current_face.face;
|
||||
}
|
||||
}
|
||||
if(!face) face = &npc_male;
|
||||
|
||||
}
|
||||
|
||||
uint32_t dialogStart = currentData->dialogID;
|
||||
|
||||
|
@ -130,7 +157,20 @@ void player_action(Game *game) {
|
|||
|
||||
/* we use the correct image as per the class of the item */
|
||||
|
||||
bopti_image_t *face = &NPC_Icon_img;
|
||||
ExtraData *currentData = &game->map_level->extradata[game->player.whichAction];
|
||||
bopti_image_t *face = &npc_male;
|
||||
/* It's a NPC */
|
||||
/* (Mibi88) TODO: Use string hash + strcmp if the hashes match for
|
||||
* fast string comparison. */
|
||||
face = NULL;
|
||||
for(i=0;i<FACES;i++){
|
||||
struct Face current_face = faces[i];
|
||||
if(!strcmp(current_face.name, currentNPC->face)){
|
||||
face = current_face.face;
|
||||
}
|
||||
if(!face) face = &npc_male;
|
||||
}
|
||||
dtext(2, 64, C_BLACK, currentData->type);
|
||||
uint32_t dialogStart = currentNPC->dialogID;
|
||||
|
||||
/* we set this NPC to paused to avoid changing its position while
|
||||
|
|