Skip to content

Commit e09e907

Browse files
committed
range warning for throwing
1 parent f59961f commit e09e907

7 files changed

Lines changed: 95 additions & 76 deletions

File tree

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
bugs
22
----
33
throwing potions
4-
out of range on throw distance
54
smashing potion sound
65
thing_clone
76
item thrown onto exit

data/gfx.tgz

144 Bytes
Binary file not shown.

src/gfx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,13 +2072,13 @@ static void gfx_init_tiles()
20722072
"cursor_path.hazard",
20732073
"cursor_path.warning",
20742074
"cursor_path.target",
2075+
"cursor_path.target_out_of_range",
20752076
"cursor_at.nopath",
20762077
"cursor_at.normal",
20772078
"cursor_at.hazard",
20782079
"cursor_at.warning",
20792080
"cursor_at.target",
2080-
"",
2081-
"",
2081+
"cursor_at.target_out_of_range",
20822082
"",
20832083
"",
20842084
"",

src/my_tp.hpp

Lines changed: 60 additions & 59 deletions
Large diffs are not rendered by default.

src/thing_anim.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ void thing_anim_init(Gamep g, Levelsp v, Levelp l, Thingp t, ThingAnimType anim_
129129
case THING_ANIM_CURSOR_NOPATH :
130130
case THING_ANIM_CURSOR_HAZARD :
131131
case THING_ANIM_CURSOR_TARGET :
132+
case THING_ANIM_CURSOR_TARGET_OUT_OF_RANGE :
132133
case THING_ANIM_CURSOR_WARNING :
133134
case THING_ANIM_OPEN :
134135
case THING_ANIM_DEAD :

src/things/internal/cursor/cursor_at.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ static auto tp_cursor_at_display_get_tile_info(Gamep g, Levelsp v, Levelp l, con
2121
//
2222
Tilep tile = tp_tiles_get(tp, THING_ANIM_CURSOR_NOPATH, 0);
2323

24-
//
25-
// Targetting?
26-
//
27-
if (game_state(g) == STATE_THROW_ITEM) {
28-
return tp_tiles_get(tp, THING_ANIM_CURSOR_TARGET, 0);
29-
}
30-
3124
auto *player = thing_player(g);
3225
if (player == nullptr) [[unlikely]] {
3326
return tile;
3427
}
3528

29+
//
30+
// Not seen this tile?
31+
//
3632
if (! level_has_seen(g, v, l, p)) {
3733
return tile;
3834
}
3935

36+
//
37+
// Targetting?
38+
//
39+
if (game_state(g) == STATE_THROW_ITEM) {
40+
if (distance(p, thing_at(player)) > thing_distance_throw(g, v, l, player)) {
41+
return tp_tiles_get(tp, THING_ANIM_CURSOR_TARGET_OUT_OF_RANGE, 0);
42+
}
43+
return tp_tiles_get(tp, THING_ANIM_CURSOR_TARGET, 0);
44+
}
45+
4046
//
4147
// Non zero cursor path, change the cursor to a positive color
4248
//
@@ -94,6 +100,8 @@ static auto tp_cursor_at_display_get_tile_info(Gamep g, Levelsp v, Levelp l, con
94100
tp_tiles_push_back(tp, THING_ANIM_CURSOR_HAZARD, tile);
95101
tile = tile_find_mand("cursor_at.target");
96102
tp_tiles_push_back(tp, THING_ANIM_CURSOR_TARGET, tile);
103+
tile = tile_find_mand("cursor_at.target_out_of_range");
104+
tp_tiles_push_back(tp, THING_ANIM_CURSOR_TARGET_OUT_OF_RANGE, tile);
97105

98106
return true;
99107
}

src/things/internal/cursor/cursor_path.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,26 @@ static auto tp_cursor_path_display_get_tile_info(Gamep g, Levelsp v, Levelp l, c
2020
//
2121
Tilep tile = tp_tiles_get(tp, THING_ANIM_CURSOR_NOPATH, 0);
2222

23+
auto *player = thing_player(g);
24+
if (player == nullptr) [[unlikely]] {
25+
return tile;
26+
}
27+
2328
//
24-
// Targetting?
29+
// Not seen this tile?
2530
//
26-
if (game_state(g) == STATE_THROW_ITEM) {
27-
return tp_tiles_get(tp, THING_ANIM_CURSOR_TARGET, 0);
31+
if (! level_has_seen(g, v, l, p)) {
32+
return tile;
2833
}
2934

30-
auto *player = thing_player(g);
31-
if (player) {
32-
if (! level_has_seen(g, v, l, p)) {
33-
return tile;
35+
//
36+
// Targetting?
37+
//
38+
if (game_state(g) == STATE_THROW_ITEM) {
39+
if (distance(p, thing_at(player)) > thing_distance_throw(g, v, l, player)) {
40+
return tp_tiles_get(tp, THING_ANIM_CURSOR_TARGET_OUT_OF_RANGE, 0);
3441
}
42+
return tp_tiles_get(tp, THING_ANIM_CURSOR_TARGET, 0);
3543
}
3644

3745
if (level_is_cursor_path_warning(g, v, l, p) != nullptr) {
@@ -68,6 +76,8 @@ static auto tp_cursor_path_display_get_tile_info(Gamep g, Levelsp v, Levelp l, c
6876
tp_tiles_push_back(tp, THING_ANIM_CURSOR_HAZARD, tile);
6977
tile = tile_find_mand("cursor_path.target");
7078
tp_tiles_push_back(tp, THING_ANIM_CURSOR_TARGET, tile);
79+
tile = tile_find_mand("cursor_path.target_out_of_range");
80+
tp_tiles_push_back(tp, THING_ANIM_CURSOR_TARGET_OUT_OF_RANGE, tile);
7181

7282
return true;
7383
}

0 commit comments

Comments
 (0)