commit
5a20a42937
@ -62,8 +62,8 @@ struct walkbot_node_s {
|
||||
void unlink(index_t node) {
|
||||
for (size_t i = 0; i < connection_count; i++) {
|
||||
if (connections[i] == node) {
|
||||
connections[i] = connections[connection_count];
|
||||
connections[connection_count--] = INVALID_NODE;
|
||||
connections[i] = connections[connection_count - 1];
|
||||
connections[--connection_count] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -238,6 +238,7 @@ CatVar draw_info(CV_SWITCH, "wb_info", "1", "Walkbot info");
|
||||
CatVar draw_path(CV_SWITCH, "wb_path", "1", "Walkbot path");
|
||||
CatVar draw_nodes(CV_SWITCH, "wb_nodes", "1", "Walkbot nodes");
|
||||
CatVar draw_indices(CV_SWITCH, "wb_indices", "1", "Node indices");
|
||||
CatVar free_move(CV_SWITCH, "wb_freemove", "1", "Allow free movement", "Allow free movement while pressing movement keys");
|
||||
CatVar spawn_distance(CV_FLOAT, "wb_node_spawn_distance", "48", "Node spawn distance");
|
||||
CatVar max_distance(CV_FLOAT, "wb_replay_max_distance", "100", "Max distance to node when replaying");
|
||||
CatVar reach_distance(CV_FLOAT, "wb_replay_reach_distance", "16", "Distance where bot can be considered 'stepping' on the node");
|
||||
@ -277,7 +278,7 @@ CatCommand c_create_node("wb_create", "Create node", []() {
|
||||
}
|
||||
});
|
||||
// Connects selected node to closest one
|
||||
CatCommand c_connect_node("wb_connect", "Connect node", []() {
|
||||
CatCommand c_connect_node("wb_connect", "Connect nodes", []() {
|
||||
if (not (state::node_good(state::active_node) and state::node_good(state::closest_node)))
|
||||
return;
|
||||
// Don't link a node to itself, idiot
|
||||
@ -290,10 +291,49 @@ CatCommand c_connect_node("wb_connect", "Connect node", []() {
|
||||
a.link(state::closest_node);
|
||||
b.link(state::active_node);
|
||||
});
|
||||
// Makes a one-way connection
|
||||
CatCommand c_connect_single_node("wb_connect_single", "Connect nodes (one-way)", []() {
|
||||
if (not (state::node_good(state::active_node) and state::node_good(state::closest_node)))
|
||||
return;
|
||||
// Don't link a node to itself, idiot
|
||||
if (state::active_node == state::closest_node)
|
||||
return;
|
||||
|
||||
auto& a = state::nodes[state::active_node];
|
||||
|
||||
a.link(state::closest_node);
|
||||
});
|
||||
// Connects selected node to closest one
|
||||
CatCommand c_disconnect_node("wb_disconnect", "Disconnect nodes", []() {
|
||||
if (not (state::node_good(state::active_node) and state::node_good(state::closest_node)))
|
||||
return;
|
||||
// Don't link a node to itself, idiot
|
||||
if (state::active_node == state::closest_node)
|
||||
return;
|
||||
|
||||
auto& a = state::nodes[state::active_node];
|
||||
auto& b = state::nodes[state::closest_node];
|
||||
|
||||
a.unlink(state::closest_node);
|
||||
b.unlink(state::active_node);
|
||||
});
|
||||
// Makes a one-way connection
|
||||
CatCommand c_disconnect_single_node("wb_disconnect_single", "Connect nodes (one-way)", []() {
|
||||
if (not (state::node_good(state::active_node) and state::node_good(state::closest_node)))
|
||||
return;
|
||||
// Don't link a node to itself, idiot
|
||||
if (state::active_node == state::closest_node)
|
||||
return;
|
||||
|
||||
auto& a = state::nodes[state::active_node];
|
||||
|
||||
a.unlink(state::closest_node);
|
||||
});
|
||||
// Updates duck flag on region of nodes (selected to closest)
|
||||
// Updates a single closest node if no node is selected
|
||||
CatCommand c_update_duck("wb_duck", "Update duck flags", []() {
|
||||
index_t a = state::active_node;
|
||||
logging::Info("< DISABLED >");
|
||||
/*index_t a = state::active_node;
|
||||
index_t b = state::closest_node;
|
||||
|
||||
if (not (state::node_good(a) and state::node_good(b)))
|
||||
@ -312,7 +352,7 @@ CatCommand c_update_duck("wb_duck", "Update duck flags", []() {
|
||||
return;
|
||||
}
|
||||
bool found_next = false;
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
for (size_t i = 0; i < n.connection_count; i++) {
|
||||
if (n.connections[i] != current) {
|
||||
current = n.connections[i];
|
||||
found_next = true;
|
||||
@ -323,7 +363,7 @@ CatCommand c_update_duck("wb_duck", "Update duck flags", []() {
|
||||
logging::Info("[wb] Dead end? Can't find next node after %u", current);
|
||||
break;
|
||||
}
|
||||
} while (state::node_good(current) and (current != a));
|
||||
} while (state::node_good(current) and (current != a));*/
|
||||
});
|
||||
// Toggles jump flag on closest node
|
||||
CatCommand c_update_jump("wb_jump", "Toggle jump flag", []() {
|
||||
@ -393,7 +433,8 @@ CatCommand c_info("wb_dump", "Show info", []() {
|
||||
// Deletes a whole region of nodes
|
||||
// Deletes a single closest node if no node is selected
|
||||
CatCommand c_delete_region("wb_delete_region", "Delete region of nodes", []() {
|
||||
index_t a = state::active_node;
|
||||
logging::Info("< DISABLED >");
|
||||
/*index_t a = state::active_node;
|
||||
index_t b = state::closest_node;
|
||||
|
||||
if (not (state::node_good(a) and state::node_good(b)))
|
||||
@ -422,7 +463,7 @@ CatCommand c_delete_region("wb_delete_region", "Delete region of nodes", []() {
|
||||
logging::Info("[wb] Dead end? Can't find next node after %u", current);
|
||||
break;
|
||||
}
|
||||
} while (state::node_good(current) and (current != a));
|
||||
} while (state::node_good(current) and (current != a));*/
|
||||
});
|
||||
// Clears the state
|
||||
CatCommand c_clear("wb_clear", "Removes all nodes", []() {
|
||||
@ -502,12 +543,18 @@ index_t SelectNextNode() {
|
||||
}
|
||||
|
||||
void UpdateWalker() {
|
||||
if (free_move) {
|
||||
if (g_pUserCmd->forwardmove != 0.0f or g_pUserCmd->sidemove != 0.0f) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int jump_ticks = 0;
|
||||
if (jump_ticks > 0) {
|
||||
g_pUserCmd->buttons |= IN_JUMP;
|
||||
jump_ticks--;
|
||||
}
|
||||
bool timeout = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - state::time).count() > 2;
|
||||
bool timeout = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - state::time).count() > 1;
|
||||
if (not state::node_good(state::active_node) or timeout) {
|
||||
state::active_node = FindNearestNode();
|
||||
state::recovery = true;
|
||||
@ -596,8 +643,10 @@ void DrawNode(index_t node, bool draw_back) {
|
||||
return;
|
||||
|
||||
size_t node_size = 2;
|
||||
if (node == state::closest_node)
|
||||
node_size = 6;
|
||||
if (state::state != WB_REPLAYING) {
|
||||
if (node == state::closest_node)
|
||||
node_size = 6;
|
||||
}
|
||||
if (node == state::active_node)
|
||||
color = &colors::red;
|
||||
|
||||
@ -675,6 +724,15 @@ void Draw() {
|
||||
AddSideString("Walkbot: Replaying");
|
||||
} break;
|
||||
}
|
||||
if (draw_info) {
|
||||
AddSideString(format("Active node: ", state::active_node));
|
||||
AddSideString(format("Highlighted node: ", state::closest_node));
|
||||
AddSideString(format("Last node: ", state::last_node));
|
||||
AddSideString(format("Node count: ", state::nodes.size()));
|
||||
if (state::recovery) {
|
||||
AddSideString(format("(Recovery mode)"));
|
||||
}
|
||||
}
|
||||
if (draw_path)
|
||||
DrawPath();
|
||||
}
|
||||
@ -683,6 +741,7 @@ void Move() {
|
||||
if (state::state == WB_DISABLED) return;
|
||||
switch (state::state) {
|
||||
case WB_RECORDING: {
|
||||
UpdateClosestNode();
|
||||
if (active_recording and ShouldSpawnNode()) {
|
||||
RecordNode();
|
||||
}
|
||||
|
Reference in New Issue
Block a user