Save adventure location with team and inventory
This commit is contained in:
16 files changed
+444
-203
No files matched your search
+43
-14
@@ -87,6 +87,35 @@ int near_map_exit(int x, int y)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void reset_arrival(int x, int y)
|
||||
{
|
||||
grass_steps = 0;
|
||||
diagonal_fraction = 0;
|
||||
reset_follower(x, y);
|
||||
}
|
||||
|
||||
void default_location(struct Location *out)
|
||||
{
|
||||
out->room = OUTSIDE; out->x = 108; out->y = 103; out->facing = FACING_DOWN;
|
||||
}
|
||||
|
||||
int location_valid(const struct Location *location)
|
||||
{
|
||||
return location && location->room >= OUTSIDE && location->room < ROOM_COUNT &&
|
||||
location->facing >= FACING_DOWN && location->facing <= FACING_RIGHT &&
|
||||
location->x >= 0 && location->x < WIDTH && location->y >= 0 && location->y < HEIGHT &&
|
||||
room_walkable(location->room, location->x, location->y);
|
||||
}
|
||||
|
||||
void enter_location(const struct Location *location, int *x, int *y)
|
||||
{
|
||||
current_room = (enum Room)location->room;
|
||||
*x = location->x; *y = location->y;
|
||||
player_facing = (enum Facing)location->facing;
|
||||
door_open = 0;
|
||||
reset_arrival(*x, *y);
|
||||
}
|
||||
|
||||
/* Walk across a map boundary. Arrivals are away from the return trigger. */
|
||||
TEST_INTERNAL int use_map_exit(int *x, int *y, unsigned keys)
|
||||
{
|
||||
@@ -125,9 +154,7 @@ TEST_INTERNAL int use_map_exit(int *x, int *y, unsigned keys)
|
||||
return 0;
|
||||
}
|
||||
door_open = 0;
|
||||
grass_steps = 0;
|
||||
diagonal_fraction = 0;
|
||||
reset_follower(*x, *y);
|
||||
reset_arrival(*x, *y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -159,9 +186,7 @@ int use_door(int *x, int *y)
|
||||
}
|
||||
door_open = 0;
|
||||
player_facing = FACING_DOWN;
|
||||
grass_steps = 0;
|
||||
diagonal_fraction = 0;
|
||||
reset_follower(*x, *y);
|
||||
reset_arrival(*x, *y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -171,20 +196,24 @@ void reset_position(int *x, int *y)
|
||||
*y = indoors() ? 119 : (current_room == ROUTE || current_room == BEACH) ? 60 :
|
||||
current_room == MELLON_GARDEN ? 113 : 103;
|
||||
player_facing = FACING_DOWN;
|
||||
grass_steps = 0;
|
||||
diagonal_fraction = 0;
|
||||
reset_follower(*x, *y);
|
||||
reset_arrival(*x, *y);
|
||||
}
|
||||
|
||||
TEST_INTERNAL int can_walk(int x, int y)
|
||||
{
|
||||
if (current_room == BEACH) {
|
||||
return room_walkable(current_room, x, y);
|
||||
}
|
||||
|
||||
int room_walkable(int room, int x, int y)
|
||||
{
|
||||
if (room < OUTSIDE || room >= ROOM_COUNT) return 0;
|
||||
if (room == BEACH) {
|
||||
if (x < 17 || x > 222 || y < 47 || y > beach_shoreline(x) - 5) return 0;
|
||||
if ((x < 42 || x > 194) && y < 72) return 0; /* Palm trunks. */
|
||||
if (x > 35 && x < 75 && y > 68 && y < 98) return 0; /* Umbrella and towel. */
|
||||
return 1;
|
||||
}
|
||||
if (current_room == ROUTE) {
|
||||
if (room == ROUTE) {
|
||||
if (x < 32 || x > 207 || y < 47 || y > 131) return 0;
|
||||
if (x > 143 && x < 216 && y < 85) return 0; /* Pond. */
|
||||
if (x > 116 && x < 154 && y > 53 && y < 79) return 0; /* Sign. */
|
||||
@@ -193,19 +222,19 @@ TEST_INTERNAL int can_walk(int x, int y)
|
||||
y > RANGER_Y - 9 && y < RANGER_Y + 9) return 0;
|
||||
return 1;
|
||||
}
|
||||
if (indoors()) {
|
||||
if (room == COTTAGE || room == MELLON_HOUSE) {
|
||||
if (x < 34 || x > 205 || y < 75 || y > 131) return 0;
|
||||
if (x > 26 && x < 77 && y < 105) return 0; /* Bed. */
|
||||
if (x > 141 && x < 196 && y < 109) return 0; /* Table. */
|
||||
if (x > 187 && y < 85) return 0; /* Plant. */
|
||||
if (current_room == MELLON_HOUSE && x > PROF_X - 13 && x < PROF_X + 13 &&
|
||||
if (room == MELLON_HOUSE && x > PROF_X - 13 && x < PROF_X + 13 &&
|
||||
y > PROF_Y - 9 && y < PROF_Y + 9) return 0;
|
||||
return 1;
|
||||
}
|
||||
if (x < 17 || x > 222 || y < 47 || y > 131) return 0;
|
||||
if (x > 16 && x < 82 && y > 42 && y < 92) return 0;
|
||||
if (x > 141 && x < 212 && y < 78) return 0;
|
||||
if (current_room == OUTSIDE && x > NPC_X - 13 && x < NPC_X + 13 &&
|
||||
if (room == OUTSIDE && x > NPC_X - 13 && x < NPC_X + 13 &&
|
||||
y > NPC_Y - 9 && y < NPC_Y + 9) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user