Zone 1 npcs

This commit is contained in:
Pyrex 2024-02-29 13:20:18 -08:00
parent 1a89e4f3b6
commit 0a3a8cb8ab
7 changed files with 288 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 623 B

View File

@ -19,8 +19,12 @@ typedef struct {
uint8_t shine; uint8_t shine;
} game_npc_palette; } game_npc_palette;
game_npc_palette game_npc_palettes[1] = { game_npc_palette game_npc_palettes[5] = {
{14, 12, 13, 6, 7, 6, 7, 0, 8, 7} {14, 13, 12, 6, 7, 6, 7, 0, 8, 7},
{4, 2, 3, 6, 7, 9, 10, 0, 4, 7},
{13, 0, 1, 1, 13, 11, 10, 0, 13, 7},
{7, 14, 7, 14, 7, 14, 7, 0, 14, 7},
{12, 1, 13, 12, 6, 8, 7, 0, 8, 7}
}; };
#define GAME_NPC_N_PALETTES (sizeof(game_npc_palettes)/sizeof(game_npc_palettes[0])) #define GAME_NPC_N_PALETTES (sizeof(game_npc_palettes)/sizeof(game_npc_palettes[0]))
@ -40,6 +44,7 @@ game_npc* game_npc_create(sys_i32 x, sys_i32 y) {
.palette_id = 0, .palette_id = 0,
.inflict_id = 0, .inflict_id = 0,
.face_left = false, .face_left = false,
.flip = false,
.n_dialogues = 0, .n_dialogues = 0,
.no_cake_dialogue = NULL, .no_cake_dialogue = NULL,
@ -90,7 +95,7 @@ void game_npc_trigger_dialogue(sys_i32 npc_id) {
if ( if (
!npc->received_cake && !npc->received_cake &&
game_player_collectibles.n_cake == 0 && game_player_collectibles.n_cake <= 0 &&
npc->no_cake_dialogue != NULL npc->no_cake_dialogue != NULL
) { ) {
dialogue = npc->no_cake_dialogue; dialogue = npc->no_cake_dialogue;
@ -135,8 +140,8 @@ void game_npcs_draw() {
} }
sys_dpal_set(14, palette.main); sys_dpal_set(14, palette.main);
sys_dpal_set(12, palette.alt0_0); sys_dpal_set(13, palette.alt0_0);
sys_dpal_set(13, palette.alt0_1); sys_dpal_set(12, palette.alt0_1);
sys_dpal_set(6, palette.alt1_0); sys_dpal_set(6, palette.alt1_0);
sys_dpal_set(7, palette.alt1_1); sys_dpal_set(7, palette.alt1_1);
sys_dpal_set(9, palette.eye_0); sys_dpal_set(9, palette.eye_0);
@ -154,7 +159,7 @@ void game_npcs_draw() {
2, 2,
2, 2,
n->face_left, n->face_left,
false n->flip
); );
sys_dpal_reset(); sys_dpal_reset();

View File

@ -14,6 +14,7 @@ typedef struct {
uint8_t palette_id; uint8_t palette_id;
uint8_t inflict_id; uint8_t inflict_id;
bool face_left; bool face_left;
bool flip;
uint8_t n_dialogues; uint8_t n_dialogues;
const char* no_cake_dialogue; const char* no_cake_dialogue;

View File

@ -11,7 +11,7 @@
"iid": "7db5fd20-b0a0-11ee-9688-af2c6adbc1d6", "iid": "7db5fd20-b0a0-11ee-9688-af2c6adbc1d6",
"jsonVersion": "1.5.3", "jsonVersion": "1.5.3",
"appBuildId": 473703, "appBuildId": 473703,
"nextUid": 131, "nextUid": 132,
"identifierStyle": "Lowercase", "identifierStyle": "Lowercase",
"toc": [], "toc": [],
"worldLayout": "Free", "worldLayout": "Free",
@ -3733,6 +3733,43 @@
"allowedRefsEntityUid": null, "allowedRefsEntityUid": null,
"allowedRefTags": [], "allowedRefTags": [],
"tilesetUid": null "tilesetUid": null
},
{
"identifier": "flip",
"doc": null,
"__type": "Bool",
"uid": 131,
"type": "F_Bool",
"isArray": false,
"canBeNull": false,
"arrayMinLength": null,
"arrayMaxLength": null,
"editorDisplayMode": "Hidden",
"editorDisplayScale": 1,
"editorDisplayPos": "Above",
"editorLinkStyle": "StraightArrow",
"editorDisplayColor": null,
"editorAlwaysShow": false,
"editorShowInWorld": true,
"editorCutLongValues": true,
"editorTextSuffix": null,
"editorTextPrefix": null,
"useForSmartColor": false,
"exportToToc": false,
"searchable": false,
"min": null,
"max": null,
"regex": null,
"acceptFileTypes": null,
"defaultOverride": null,
"textLanguageMode": null,
"symmetricalRef": false,
"autoChainRef": true,
"allowOutOfLevelRef": true,
"allowedRefs": "OnlySame",
"allowedRefsEntityUid": null,
"allowedRefTags": [],
"tilesetUid": null
} }
] ]
} }
@ -3804,14 +3841,14 @@
} }
}, },
{ {
"__cWid": 8, "__cWid": 32,
"__cHei": 8, "__cHei": 2,
"identifier": "game_npcs", "identifier": "game_npcs",
"uid": 123, "uid": 123,
"relPath": "../art/game_npcs.png", "relPath": "../art/game_npcs.png",
"embedAtlas": null, "embedAtlas": null,
"pxWid": 64, "pxWid": 256,
"pxHei": 64, "pxHei": 16,
"tileGridSize": 8, "tileGridSize": 8,
"spacing": 0, "spacing": 0,
"padding": 0, "padding": 0,
@ -3822,7 +3859,7 @@
"savedSelections": [], "savedSelections": [],
"cachedPixelData": { "cachedPixelData": {
"opaqueTiles": "0000000000000000000000000000000000000000000000000000000000000000", "opaqueTiles": "0000000000000000000000000000000000000000000000000000000000000000",
"averageColors": "bd8aae896b897d7a86ba8c899c9aae89daac9bbc7c8b489b7d8a69aadaac9bbc49aa5c9b0000000000000000000000007c8b489b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "averageColors": "bd8aae896b897d7a8c79988b9c9aae8949aa5c9b499c4d8b6c9c6a9a000000000000000000000000000000000000000000000000000000000000000000000000daac9bbc7c8b489b7c8b778adaac9bbc7c8b489b9d9a8d9a8b79979b000000000000000000000000000000000000000000000000000000000000000000000000"
} }
} }
], "enums": [], "externalEnums": [], "levelFields": [] }, ], "enums": [], "externalEnums": [], "levelFields": [] },
@ -3918,11 +3955,12 @@
"id": "V_String", "id": "V_String",
"params": ["Don't worry! We'll meet again."] "params": ["Don't worry! We'll meet again."]
} ] }, } ] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": null, "__tile": null, "defUid": 129, "realEditorValues": [] }, { "__identifier": "no_cake_dialogue", "__type": "String", "__value": null, "__tile": null, "defUid": 129, "realEditorValues": [null] },
{ "__identifier": "face_left", "__type": "Bool", "__value": true, "__tile": null, "defUid": 130, "realEditorValues": [{ { "__identifier": "face_left", "__type": "Bool", "__value": true, "__tile": null, "defUid": 130, "realEditorValues": [{
"id": "V_Bool", "id": "V_Bool",
"params": [ true ] "params": [ true ]
}] } }] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [] }
], ],
"__worldX": 464, "__worldX": 464,
"__worldY": 528 "__worldY": 528
@ -4318,7 +4356,84 @@
"seed": 8688237, "seed": 8688237,
"overrideTilesetUid": null, "overrideTilesetUid": null,
"gridTiles": [], "gridTiles": [],
"entityInstances": [] "entityInstances": [
{
"__identifier": "npc",
"__grid": [6,15],
"__pivot": [0,0],
"__tags": [],
"__tile": { "tilesetUid": 123, "x": 0, "y": 0, "w": 16, "h": 16 },
"__smartColor": "#E4A672",
"iid": "e6352c60-b0a0-11ee-9688-6dac1e5705ce",
"width": 16,
"height": 16,
"defUid": 122,
"px": [48,120],
"fieldInstances": [
{ "__identifier": "sprite_id", "__type": "Int", "__value": 8, "__tile": null, "defUid": 125, "realEditorValues": [{ "id": "V_Int", "params": [8] }] },
{ "__identifier": "palette_id", "__type": "Int", "__value": 1, "__tile": null, "defUid": 126, "realEditorValues": [{ "id": "V_Int", "params": [1] }] },
{ "__identifier": "inflict_id", "__type": "Int", "__value": 0, "__tile": null, "defUid": 127, "realEditorValues": [] },
{ "__identifier": "dialogue", "__type": "Array<String>", "__value": [
"Thank you, and happy birthday!",
"I'm going to rest here a while longer.",
"You can rest too, if you like."
], "__tile": null, "defUid": 124, "realEditorValues": [ {
"id": "V_String",
"params": ["Thank you, and happy birthday!"]
}, {
"id": "V_String",
"params": ["I'm going to rest here a while longer."]
}, {
"id": "V_String",
"params": ["You can rest too, if you like."]
} ] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": "If I had some cake, I could get out of this pit.", "__tile": null, "defUid": 129, "realEditorValues": [{
"id": "V_String",
"params": ["If I had some cake, I could get out of this pit."]
}] },
{ "__identifier": "face_left", "__type": "Bool", "__value": true, "__tile": null, "defUid": 130, "realEditorValues": [{
"id": "V_Bool",
"params": [ true ]
}] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [] }
],
"__worldX": 560,
"__worldY": 552
},
{
"__identifier": "npc",
"__grid": [24,1],
"__pivot": [0,0],
"__tags": [],
"__tile": { "tilesetUid": 123, "x": 0, "y": 0, "w": 16, "h": 16 },
"__smartColor": "#E4A672",
"iid": "d92df2d0-b0a0-11ee-9688-e71a28a9295e",
"width": 16,
"height": 16,
"defUid": 122,
"px": [192,8],
"fieldInstances": [
{ "__identifier": "sprite_id", "__type": "Int", "__value": 2, "__tile": null, "defUid": 125, "realEditorValues": [{ "id": "V_Int", "params": [2] }] },
{ "__identifier": "palette_id", "__type": "Int", "__value": 1, "__tile": null, "defUid": 126, "realEditorValues": [{ "id": "V_Int", "params": [1] }] },
{ "__identifier": "inflict_id", "__type": "Int", "__value": 0, "__tile": null, "defUid": 127, "realEditorValues": [] },
{ "__identifier": "dialogue", "__type": "Array<String>", "__value": [ "Thank you! Happy birthday.", "Do you have any seeds?" ], "__tile": null, "defUid": 124, "realEditorValues": [ {
"id": "V_String",
"params": ["Thank you! Happy birthday."]
}, {
"id": "V_String",
"params": ["Do you have any seeds?"]
} ] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": "My sister is in the pit, eating seeds.", "__tile": null, "defUid": 129, "realEditorValues": [{
"id": "V_String",
"params": ["My sister is in the pit, eating seeds."]
}] },
{ "__identifier": "face_left", "__type": "Bool", "__value": false, "__tile": null, "defUid": 130, "realEditorValues": [] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [] }
],
"__worldX": 704,
"__worldY": 440
}
]
}, },
{ {
"__identifier": "conceptual", "__identifier": "conceptual",
@ -4602,6 +4717,42 @@
"fieldInstances": [], "fieldInstances": [],
"__worldX": 568, "__worldX": 568,
"__worldY": 336 "__worldY": 336
},
{
"__identifier": "npc",
"__grid": [29,8],
"__pivot": [0,0],
"__tags": [],
"__tile": { "tilesetUid": 123, "x": 0, "y": 0, "w": 16, "h": 16 },
"__smartColor": "#E4A672",
"iid": "563a51a0-b0a0-11ee-9688-6fc3daf60dc3",
"width": 16,
"height": 16,
"defUid": 122,
"px": [232,64],
"fieldInstances": [
{ "__identifier": "sprite_id", "__type": "Int", "__value": 10, "__tile": null, "defUid": 125, "realEditorValues": [{ "id": "V_Int", "params": [10] }] },
{ "__identifier": "palette_id", "__type": "Int", "__value": 2, "__tile": null, "defUid": 126, "realEditorValues": [{ "id": "V_Int", "params": [2] }] },
{ "__identifier": "inflict_id", "__type": "Int", "__value": 0, "__tile": null, "defUid": 127, "realEditorValues": [] },
{ "__identifier": "dialogue", "__type": "Array<String>", "__value": [ "I'm grateful that you remembered me.", "Oh, and happy birthday." ], "__tile": null, "defUid": 124, "realEditorValues": [ {
"id": "V_String",
"params": ["I'm grateful that you remembered me."]
}, {
"id": "V_String",
"params": ["Oh, and happy birthday."]
} ] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": "Actually, the jump can be made. But not by me.", "__tile": null, "defUid": 129, "realEditorValues": [{
"id": "V_String",
"params": ["Actually, the jump can be made. But not by me."]
}] },
{ "__identifier": "face_left", "__type": "Bool", "__value": true, "__tile": null, "defUid": 130, "realEditorValues": [{
"id": "V_Bool",
"params": [ true ]
}] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [] }
],
"__worldX": 744,
"__worldY": 352
} }
] ]
}, },
@ -5235,6 +5386,39 @@
"fieldInstances": [], "fieldInstances": [],
"__worldX": 800, "__worldX": 800,
"__worldY": 472 "__worldY": 472
},
{
"__identifier": "npc",
"__grid": [5,9],
"__pivot": [0,0],
"__tags": [],
"__tile": { "tilesetUid": 123, "x": 0, "y": 0, "w": 16, "h": 16 },
"__smartColor": "#E4A672",
"iid": "4cd1c2a0-b0a0-11ee-9688-bd24156e1d20",
"width": 16,
"height": 16,
"defUid": 122,
"px": [40,72],
"fieldInstances": [
{ "__identifier": "sprite_id", "__type": "Int", "__value": 12, "__tile": null, "defUid": 125, "realEditorValues": [{ "id": "V_Int", "params": [12] }] },
{ "__identifier": "palette_id", "__type": "Int", "__value": 2, "__tile": null, "defUid": 126, "realEditorValues": [{ "id": "V_Int", "params": [2] }] },
{ "__identifier": "inflict_id", "__type": "Int", "__value": 0, "__tile": null, "defUid": 127, "realEditorValues": [] },
{ "__identifier": "dialogue", "__type": "Array<String>", "__value": ["My kin and I thank you. By the way, there's money in the cave."], "__tile": null, "defUid": 124, "realEditorValues": [{
"id": "V_String",
"params": ["My kin and I thank you. By the way, there's money in the cave."]
}] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": "... No cake? That's too bad. You'll need to backtrack.", "__tile": null, "defUid": 129, "realEditorValues": [{
"id": "V_String",
"params": ["... No cake? That's too bad. You'll need to backtrack."]
}] },
{ "__identifier": "face_left", "__type": "Bool", "__value": false, "__tile": null, "defUid": 130, "realEditorValues": [] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [{
"id": "V_Bool",
"params": [ false ]
}] }
],
"__worldX": 808,
"__worldY": 504
} }
] ]
}, },
@ -5864,7 +6048,41 @@
"seed": 6163427, "seed": 6163427,
"overrideTilesetUid": null, "overrideTilesetUid": null,
"gridTiles": [], "gridTiles": [],
"entityInstances": [] "entityInstances": [
{
"__identifier": "npc",
"__grid": [22,2],
"__pivot": [0,0],
"__tags": [],
"__tile": { "tilesetUid": 123, "x": 0, "y": 0, "w": 16, "h": 16 },
"__smartColor": "#E4A672",
"iid": "7111d260-b0a0-11ee-9688-57444a95bb5f",
"width": 16,
"height": 16,
"defUid": 122,
"px": [176,16],
"fieldInstances": [
{ "__identifier": "sprite_id", "__type": "Int", "__value": 6, "__tile": null, "defUid": 125, "realEditorValues": [{ "id": "V_Int", "params": [6] }] },
{ "__identifier": "palette_id", "__type": "Int", "__value": 3, "__tile": null, "defUid": 126, "realEditorValues": [{ "id": "V_Int", "params": [3] }] },
{ "__identifier": "inflict_id", "__type": "Int", "__value": 0, "__tile": null, "defUid": 127, "realEditorValues": [] },
{ "__identifier": "dialogue", "__type": "Array<String>", "__value": ["I don't know what to say! Thank you."], "__tile": null, "defUid": 124, "realEditorValues": [{
"id": "V_String",
"params": ["I don't know what to say! Thank you."]
}] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": "How did you get to me? And without cake?", "__tile": null, "defUid": 129, "realEditorValues": [{
"id": "V_String",
"params": ["How did you get to me? And without cake?"]
}] },
{ "__identifier": "face_left", "__type": "Bool", "__value": true, "__tile": null, "defUid": 130, "realEditorValues": [{
"id": "V_Bool",
"params": [ true ]
}] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [] }
],
"__worldX": 944,
"__worldY": 160
}
]
}, },
{ {
"__identifier": "conceptual", "__identifier": "conceptual",
@ -6161,7 +6379,47 @@
"seed": 3325108, "seed": 3325108,
"overrideTilesetUid": null, "overrideTilesetUid": null,
"gridTiles": [], "gridTiles": [],
"entityInstances": [] "entityInstances": [
{
"__identifier": "npc",
"__grid": [15,7],
"__pivot": [0,0],
"__tags": [],
"__tile": { "tilesetUid": 123, "x": 0, "y": 0, "w": 16, "h": 16 },
"__smartColor": "#E4A672",
"iid": "acf05c20-b0a0-11ee-9688-7766865c5531",
"width": 16,
"height": 16,
"defUid": 122,
"px": [120,56],
"fieldInstances": [
{ "__identifier": "sprite_id", "__type": "Int", "__value": 4, "__tile": null, "defUid": 125, "realEditorValues": [{ "id": "V_Int", "params": [4] }] },
{ "__identifier": "palette_id", "__type": "Int", "__value": 4, "__tile": null, "defUid": 126, "realEditorValues": [{ "id": "V_Int", "params": [4] }] },
{ "__identifier": "inflict_id", "__type": "Int", "__value": 1, "__tile": null, "defUid": 127, "realEditorValues": [{ "id": "V_Int", "params": [1] }] },
{ "__identifier": "dialogue", "__type": "Array<String>", "__value": [
"Birthday cake. Yes... delicious. Now focus... on the eyes...",
"I'm very, very good at that."
], "__tile": null, "defUid": 124, "realEditorValues": [ {
"id": "V_String",
"params": ["Birthday cake. Yes... delicious. Now focus... on the eyes..."]
}, {
"id": "V_String",
"params": ["I'm very, very good at that."]
} ] },
{ "__identifier": "no_cake_dialogue", "__type": "String", "__value": "No cake? My kin should have given you instructions in the cave.", "__tile": null, "defUid": 129, "realEditorValues": [{
"id": "V_String",
"params": ["No cake? My kin should have given you instructions in the cave."]
}] },
{ "__identifier": "face_left", "__type": "Bool", "__value": true, "__tile": null, "defUid": 130, "realEditorValues": [{
"id": "V_Bool",
"params": [ true ]
}] },
{ "__identifier": "flip", "__type": "Bool", "__value": false, "__tile": null, "defUid": 131, "realEditorValues": [] }
],
"__worldX": 1144,
"__worldY": 200
}
]
}, },
{ {
"__identifier": "conceptual", "__identifier": "conceptual",

View File

@ -67,6 +67,11 @@ void map_game_map_npc_set_face_left(bool face_left) {
game_map_npc_in_progress->face_left = face_left; game_map_npc_in_progress->face_left = face_left;
} }
void map_game_map_npc_set_flip(bool flip) {
assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->flip = flip;
}
void map_game_map_npc_set_no_cake_dialogue(const char* dialogue) { void map_game_map_npc_set_no_cake_dialogue(const char* dialogue) {
assert(game_map_npc_in_progress && "NPC has to be in progress"); assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->no_cake_dialogue = dialogue; game_map_npc_in_progress->no_cake_dialogue = dialogue;

View File

@ -131,13 +131,13 @@ def load_mapdata(fname_ldtk):
def format_field_value(ty, val): def format_field_value(ty, val):
if ty == "Bool": if ty == "Bool":
return "true" if val else "false", "scalar", "bool" return ("true" if val else "false"), "scalar", "bool"
elif ty == "Int": elif ty == "Int":
return str(val), "scalar", "sys_i32" return str(val), "scalar", "sys_i32"
elif ty == "String": elif ty == "String":
if val is None: if val is None:
return "NULL", "scalar", "const char*" return "NULL", "scalar", "const char*"
return json.dumps(wrap(val)), "scalar" # this is close enough to being right in C return json.dumps(wrap(val)), "scalar", "const char*" # this is close enough to being right in C
elif ty == "Array<Int>": elif ty == "Array<Int>":
return [format_field_value("Int", i)[0] for i in val], "array", "sys_i32" return [format_field_value("Int", i)[0] for i in val], "array", "sys_i32"
elif ty == "Array<String>": elif ty == "Array<String>":