Fix empty wandering monster bug. Fix #723

This commit is contained in:
2025-04-21 10:34:37 -05:00
parent bd13f2f75f
commit acc1b0d40a
2 changed files with 17 additions and 8 deletions

View File

@@ -108,7 +108,9 @@ std::map<std::string,std::vector<std::string>> feature_flags = {
{"target-lock", {"V1"}},
// New in-game save file picker
{"file-picker-dialog", {"V1"}},
{"scenario-meta-format", {"V2"}}
{"scenario-meta-format", {"V2"}},
// Bugs required for several VoDT test replays to run faithfully
{"empty-wandering-monster-bug", {"fixed"}}
};
struct cParseEntrance {

View File

@@ -60,6 +60,19 @@ void create_wand_monst() {
while(point_onscreen(univ.town->wandering_locs[r2],univ.party.town_loc) &&
!loc_off_act_area(univ.town->wandering_locs[r2]) && num_tries++ < 100)
r2 = get_ran(1,0,3);
auto try_place_extra_monster = [&p_loc, r1, r2, &r3](){
p_loc = univ.town->wandering_locs[r2];
p_loc.x += get_ran(1,0,4) - 2;
p_loc.y += get_ran(1,0,4) - 2;
r3 = get_ran(1,0,3);
// Buggy behavior of this code, preserved so old replays will run correctly,
// would spawn nameless monsters of type 0 with default stats.
if(r3 >= 2 && !is_blocked(p_loc) &&
(univ.town->wandering[r1].monst[3] != 0 || !has_feature_flag("empty-wandering-monster-bug", "fixed")))
// place extra monsters
place_monster(univ.town->wandering[r1].monst[3],p_loc);
};
for(short i = 0; i < 4; i++) {
if(univ.town->wandering[r1].monst[i] != 0) { // place a monster
p_loc = univ.town->wandering_locs[r2];
@@ -68,13 +81,7 @@ void create_wand_monst() {
if(!is_blocked(p_loc))
place_monster(univ.town->wandering[r1].monst[i],p_loc);
}
p_loc = univ.town->wandering_locs[r2];
p_loc.x += get_ran(1,0,4) - 2;
p_loc.y += get_ran(1,0,4) - 2;
// TODO: This contradicts the documentation which says only 1-2 are placed of the last monster
r3 = get_ran(1,0,3);
if(r3 >= 2 && !is_blocked(p_loc)) // place extra monsters?
place_monster(univ.town->wandering[r1].monst[3],p_loc);
try_place_extra_monster();
}
}
}