Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Version 1.6.0 (TBD): Not yet released
### Minor features, changes, and enhancements

### Bug fixes
[@GooberRF](https://github.com/GooberRF)
- Fix Scavenger objective failing to spawn on levels with many items
- Fix Scavenger capture zone and Salvage flag spawn sometimes being placed on the floor below a grating, mesh or clutter

Version 1.5.0 (Trillium): Released Nov-20-2026
--------------------------------
Expand Down
86 changes: 86 additions & 0 deletions game_patch/misc/waypoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,92 @@ bool trace_ground_below_point(const rf::Vector3& pos, float max_downward_dist, r
return world_hit;
}

namespace
{
// obj_pair_should_skip (0x0048BE00) pairs a player with clutter only above this radius (0x005893C0); mode-0
// Alpine meshes and clutter without collision spheres have a smaller one
constexpr float kPlayerCollideMinClutterRadius = 0.5f;

bool clutter_is_player_floor(const rf::Object& obj)
{
return obj.type == rf::OT_CLUTTER && obj.vmesh
&& !(obj.obj_flags & (rf::OF_DELAYED_DELETE | rf::OF_WEAPON_ONLY_COLLIDE))
&& obj.p_data.radius > kPlayerCollideMinClutterRadius;
}

bool obj_is_mover_member(const rf::Object& obj)
{
for (rf::Object* o = rf::object_list.next_obj; o != &rf::object_list; o = o->next_obj) {
if (o->type != rf::OT_MOVER) {
continue;
}
const auto& handles = static_cast<const rf::Mover*>(o)->object_handles;
for (int i = 0; i < handles.size(); ++i) {
if (handles[i] == obj.handle) {
return true;
}
}
}
return false;
}
} // namespace

bool trace_floor_below_point_with_objects(const rf::Vector3& pos, float max_downward_dist, rf::Vector3* out_hit_point)
{
if (max_downward_dist <= 0.0f) {
return false;
}
const rf::Vector3 seg{0.0f, -max_downward_dist, 0.0f};
const rf::Vector3 end = pos + seg;

rf::Vector3 best_hit{};
bool hit = trace_ground_below_point(pos, max_downward_dist, &best_hit, true);
float best = hit ? (pos.y - best_hit.y) / max_downward_dist : 1.0f;

// Brush-mode meshes have their own solver and no object pair
AlpineMeshContact contact{};
if (alpine_mesh_collide_sphere_world(pos, end, 0.0f, nullptr, best, contact) && contact.obj_handle < 0) {
best = contact.fraction;
best_hit = contact.hit_point;
hit = true;
}

for (rf::Object* obj = rf::object_list.next_obj; obj != &rf::object_list; obj = obj->next_obj) {
if (!clutter_is_player_floor(*obj) || alpine_mesh_is_collision_mesh(obj)) {
continue;
}
const rf::Vector3& bmin = obj->p_data.bbox_min;
const rf::Vector3& bmax = obj->p_data.bbox_max;
if (pos.x < bmin.x || pos.x > bmax.x || pos.z < bmin.z || pos.z > bmax.z || end.y > bmax.y
|| pos.y < bmin.y) {
continue;
}
// A floor that moves would leave the traced height stale
if (obj_is_mover_member(*obj)) {
continue;
}
// The same vmesh test the player pair runs (collide_object_object_mesh 0x0049AFE0)
rf::VMeshCollisionInput in;
rf::VMeshCollisionOutput out;
in.mesh_pos = obj->p_data.pos;
in.mesh_orient = obj->p_data.orient;
in.start_pos = pos;
in.dir = seg;
in.radius = 0.0f;
in.flags = 0;
if (rf::vmesh_collide(obj->vmesh, &in, &out, true) && out.fraction < best) {
best = out.fraction;
best_hit = pos + seg * out.fraction;
hit = true;
}
}

if (hit && out_hit_point) {
*out_hit_point = best_hit;
}
return hit;
}

float trace_upward_clearance_from_floor_hit(
const rf::Vector3& floor_hit_pos,
float max_upward_dist,
Expand Down
4 changes: 4 additions & 0 deletions game_patch/misc/waypoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ struct WpCacheNode
// be the floor below; generation keeps the any-hit trace so the graphs it builds stay as they are.
bool trace_ground_below_point(
const rf::Vector3& pos, float max_downward_dist, rf::Vector3* out_hit_point = nullptr, bool nearest = false);
// The highest floor in reach a player can stand on, including clutter and Alpine meshes. Objects on movers are
// skipped. Not used by generation, whose traces only test level geometry and movers.
bool trace_floor_below_point_with_objects(
const rf::Vector3& pos, float max_downward_dist, rf::Vector3* out_hit_point = nullptr);

void waypoints_init();
int get_local_awp_revision(const std::string& rfl_filename);
Expand Down
20 changes: 17 additions & 3 deletions game_patch/multi/salvage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ void set_carrier(rf::Player* player)
// Server-side recovery latch for the AtSpawn path (see salvage_do_frame).
int g_respawn_retry_failures = 0;
bool g_respawn_recovery_given_up = false;
// The Delayed -> AtSpawn create failed, so the recovery spawn makes the announcement instead.
bool g_respawn_recovery_announces = false;

// Every file-scope piece of Salvage state, cleared in one place. Two sites have to
// do this — salvage_level_init, and the "game type is no longer Salvage" branch of
Expand All @@ -171,6 +173,7 @@ void reset_salvage_local_state(bool delete_light)

g_respawn_retry_failures = 0;
g_respawn_recovery_given_up = false;
g_respawn_recovery_announces = false;

if (delete_light && g_salvage_light_handle >= 0) {
rf::gr::light_delete(g_salvage_light_handle, 0);
Expand Down Expand Up @@ -575,7 +578,7 @@ void resolve_flag_spawn_pos()
if (g_salvage_info.bases_known) {
const rf::Vector3 midpoint = (g_salvage_info.base_red_pos + g_salvage_info.base_blue_pos) * 0.5f;
rf::Vector3 floor_hit{};
if (trace_ground_below_point(midpoint, kSalMidpointGroundTraceDist, &floor_hit)) {
if (trace_floor_below_point_with_objects(midpoint, kSalMidpointGroundTraceDist, &floor_hit)) {
g_salvage_info.spawn_pos = floor_hit + rf::Vector3{0.0f, kWaypointGenerateGroundOffset, 0.0f};
g_salvage_info.spawn_known = true;
xlog::info("salvage: flag spawn from snapped base midpoint at ({},{},{})",
Expand Down Expand Up @@ -609,6 +612,7 @@ void enter_delayed_state(int delay_ms)
{
g_salvage_info.state = SalFlagState::Delayed;
set_carrier(nullptr);
g_respawn_recovery_announces = false;
g_salvage_info.return_timer.invalidate();
g_salvage_info.spawn_delay_timer.set(std::max(0, delay_ms));
g_salvage_info.refresh_timer.set(kSalStateRefreshIntervalMs);
Expand Down Expand Up @@ -1472,8 +1476,13 @@ void salvage_do_frame()
spawn_flag_at_home();
afstats::on_flag_event(afstats::FlagEventKind::reset, afstats::team_none, nullptr,
g_salvage_info.spawn_pos);
announce(std::format("The {} is now available!", objective_noun()));
play_local_transition_sound(stock_sound_id::flag_respawn);
if (g_salvage_info.flag_item_handle >= 0) {
announce(std::format("The {} is now available!", objective_noun()));
play_local_transition_sound(stock_sound_id::flag_respawn);
}
else {
g_respawn_recovery_announces = true;
}
salvage_broadcast_state();
return;
}
Expand Down Expand Up @@ -1503,6 +1512,11 @@ void salvage_do_frame()
if (g_salvage_info.flag_item_handle >= 0) {
g_salvage_info.respawn_retry_timer.invalidate();
g_respawn_retry_failures = 0;
if (g_respawn_recovery_announces) {
g_respawn_recovery_announces = false;
announce(std::format("The {} is now available!", objective_noun()));
play_local_transition_sound(stock_sound_id::flag_respawn);
}
}
else if (++g_respawn_retry_failures >= kSalMaxRespawnRetries) {
g_respawn_recovery_given_up = true;
Expand Down
22 changes: 20 additions & 2 deletions game_patch/multi/scavenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,28 @@ void collect_candidates()
}
}

// Deleted rather than hidden: hidden items keep their pool slots, so a legacy level placing
// 200 items left no room for the objective on the server or on clients. Like
// remove_level_ctf_flags, nothing is replicated: clients only ever get items the server sends.
void remove_level_items()
{
rf::Item* it = rf::item_list.next;
while (it && it != &rf::item_list) {
rf::Item* next = it->next;
// CTF banners are decorative and stay.
const bool is_banner = it->info
&& (it->info->cls_name == "CTF Banner Red" || it->info->cls_name == "CTF Banner Blue");
if (!is_banner) {
rf::obj_flag_dead(it);
}
it = next;
}
}

float trace_zone_floor_y(const rf::Vector3& pos)
{
rf::Vector3 hit{};
return trace_ground_below_point(pos, kScavZoneFloorTraceDist, &hit) ? hit.y : pos.y;
return trace_floor_below_point_with_objects(pos, kScavZoneFloorTraceDist, &hit) ? hit.y : pos.y;
}

// The one place the zone changes, on either side. Only the server traces floor_y: clients handle
Expand Down Expand Up @@ -264,7 +282,7 @@ void scavenger_level_init_post()

collect_candidates();
salvage_remove_level_ctf_flags();
multi_hide_level_items({}, false);
remove_level_items();

if (g_scav_info.candidates.size() < 2) {
xlog::warn("scavenger: level has {} usable item positions, at least 2 are needed; no objective",
Expand Down
Loading