You can get the pager from the basement.

master
immibis 2025-02-19 03:51:11 +01:00
parent 4f2a0be43a
commit 785642a2c9
10 changed files with 72 additions and 6 deletions

View File

@ -62,6 +62,7 @@ navmesh_%.c: $(PROJECT_ROOT)navmesh/%.tmx $(PROJECT_ROOT)compile_navmesh.py
@# symbols are navmesh_% and predef_%
navmesh_%.o: $(PROJECT_ROOT)compiled_structures.h $(PROJECT_ROOT)objids.h
pinetab2_framework.o: $(PROJECT_ROOT)engine.h
%.png: $(PROJECT_ROOT)sprites/%.xcf
gimp -in -b '(let ((image (car (gimp-xcf-load 0 "$<" "$(notdir $<)")))) ;\

View File

@ -101,3 +101,7 @@ void blit(int x, int y, int width, int height, uint32_t *pixels);
// game.cpp
void scene_setup(scene *s, int scene, int fromscene);
void onclick(int curscene, struct object *obj);
extern struct savefile {
bool got_pager_from_basement;
} savefile;

View File

@ -13,6 +13,7 @@ extern const char _binary_sprite_lobby_raw_start[];
extern const char _binary_sprite_managers_office_raw_start[];
extern const char _binary_sprite_managers_office_safe_raw_start[];
extern const char _binary_sprite_basement_raw_start[];
extern const char _binary_sprite_item_pager_raw_start[];
extern const char _binary_sprite_stickman_raw_start[];
@ -70,6 +71,9 @@ void scene_setup(scene *me, int scene, int fromscene) {
case SCENE_BASEMENT:
scene_add_object(me, OBJID_BACKGROUND, 0, 0, BGWIDTH, BGHEIGHT, _binary_sprite_basement_raw_start);
scene_load_predef(me, &predef_basement);
if(!savefile.got_pager_from_basement) {
scene_add_object(me, OBJID_PAGER, 556, 520, 87, 87, _binary_sprite_item_pager_raw_start);
}
switch(fromscene) {
case SCENE_MANAGERS_OFFICE:
create_player(me, 435, 404);
@ -125,13 +129,56 @@ static void do_popcorn_on_walk_finish(struct script *scr, int wakeupMode, int ar
assert(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT_INTERRUPTED);
}
static void start_player_walk_to_point_then_do_popcorn(int x, int y) {
static void get_pager_on_walk_finish(struct script *scr, int wakeupMode, int arg1, int arg2, int arg3, int arg4) {
scr->id = 0;
if(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT) {
struct object *obj = find_object_by_id(OBJID_PAGER);
if(obj) {
if(add_to_inventory(INVITEM_PAGER) < 0) {
push_scene_textbox("Inventory is full.");
} else {
obj->id = 0;
savefile.got_pager_from_basement = true;
push_scene_textbox(
"You found your pager.\n"
"Now you can get out of here."
);
}
}
}
else
assert(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT_INTERRUPTED);
}
static void start_player_walk_to_point_then(int x, int y, script_wake_fn wake_fn) {
start_player_walk_to_point(x, y);
struct script *scr = scene_add_script(OBJID_PLAYER_WALK_TO_DOOR_SCRIPT, true);
scr->wakeupMode = SCRIPT_WAKEUP_OTHER_SCRIPT;
scr->wakeupArg1 = OBJID_PLAYER_WALK_SCRIPT;
scr->wakeupFn = do_popcorn_on_walk_finish;
scr->wakeupFn = wake_fn;
}
static void do_leave_lobby_on_walk_finish(struct script *scr, int wakeupMode, int arg1, int arg2, int arg3, int arg4) {
scr->id = 0;
if(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT) {
if(count_item_in_inventory(INVITEM_PAGER) == 0) {
push_scene_textbox(
"You can't leave without\n"
"finding your pager."
);
} else {
push_scene_textbox(
"You got killed in a mugging\n"
"and we rewound time for you,\n"
"as required by the plot to\n"
"keep you inside the theatre."
);
}
}
else
assert(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT_INTERRUPTED);
}
void onclick(int curscene, struct object *obj) {
@ -150,6 +197,9 @@ void onclick(int curscene, struct object *obj) {
case OBJID_DOOR_TO_MANAGERS_OFFICE_FROM_LOBBY:
start_player_walk_to_point_then_transition_scene(256, 441, SCENE_MANAGERS_OFFICE);
return;
case OBJID_LEAVE_ROOM:
start_player_walk_to_point_then(obj->x + obj->width/2, obj->y + obj->height, do_leave_lobby_on_walk_finish);
return;
}
break;
case SCENE_MANAGERS_OFFICE:
@ -171,7 +221,10 @@ void onclick(int curscene, struct object *obj) {
start_player_walk_to_point_then_transition_scene(438, 402, SCENE_MANAGERS_OFFICE);
return;
case OBJID_POPCORN_BARREL:
start_player_walk_to_point_then_do_popcorn(obj->x + obj->width/2, obj->y + obj->height);
start_player_walk_to_point_then(obj->x + obj->width/2, obj->y + obj->height, do_popcorn_on_walk_finish);
return;
case OBJID_PAGER:
start_player_walk_to_point_then(obj->x + obj->width/2, obj->y + obj->height, get_pager_on_walk_finish);
return;
}
break;

View File

@ -5,9 +5,11 @@
extern const char _binary_sprite_menubar_raw_start[];
extern const char _binary_sprite_item_popcorn_raw_start[];
extern const char _binary_sprite_item_pager_raw_start[];
static const char *const inventory_sprites[] = {
_binary_sprite_item_popcorn_raw_start
_binary_sprite_item_popcorn_raw_start,
_binary_sprite_item_pager_raw_start,
};
int inventory[INVENTORY_SIZE] = {

View File

@ -2,6 +2,7 @@ enum invobject {
INVITEM_BLANK = 0, // must always be 0
INVITEM_POPCORN,
INVITEM_PAGER,
};
extern int inventory[INVENTORY_SIZE];

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="40" height="25" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="19">
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="40" height="25" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="20">
<imagelayer id="2" name="Image Layer 1">
<image source="../build/default/lobby.png" width="1280" height="800"/>
<image source="../build/default/lobby.png" width="1066" height="800"/>
</imagelayer>
<objectgroup id="3" name="clickable">
<object id="1" name="OBJID_DOOR_TO_MANAGERS_OFFICE_FROM_LOBBY" x="227" y="312" width="64" height="128"/>
<object id="19" name="OBJID_LEAVE_ROOM" x="468" y="720" width="83" height="79"/>
</objectgroup>
<objectgroup id="4" name="navmesh">
<object id="10" x="178" y="440">

View File

@ -12,5 +12,7 @@
#define OBJID_CLOSE_MODAL 12
#define OBJID_POPCORN_BARREL 13
#define OBJID_MENUBAR 14
#define OBJID_LEAVE_ROOM 15
#define OBJID_PAGER 16
#define OBJID_INVENTORY_SLOTS 0x10000000 // + slot number

View File

@ -31,6 +31,8 @@ struct scene scenes[MAX_STACKED_SCENES];
int scene_depth = 0;
bool need_rerender = false;
struct savefile savefile;
#define MAX_MT_SLOTS 16

BIN
sprites/item_pager.xcf Normal file

Binary file not shown.

Binary file not shown.