-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alias spectate command to camera2 in SP, add help strings for cheat commands #287
base: master
Are you sure you want to change the base?
Conversation
Personally I do not see usefulness especially for |
|
I do not like Further
|
Good point, fixed.
I disagree. It's a relevant factor and while the original game does not, it is vastly more intuitive to tell a player who enters a command why that command had no effect, rather than simply telling them nothing.
Good point as well, I've refactored that code to address this.
It does, and I'm a huge fan of it. It does not, however, serve even a somewhat similar purpose or address the same issue that this PR does. |
@@ -144,4 +144,5 @@ namespace rf | |||
static auto& hud_weapon_cycle_current_idx = addr_as_ref<int>(0x007C71A8); | |||
|
|||
static auto& hud_do_frame = addr_as_ref<void(Player*)>(0x00437B80); | |||
static auto& hud_msg = addr_as_ref<void(const char* text, int, int duration, Color*)>(0x004383C0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static auto& hud_msg = addr_as_ref<void(const char* text, int, int duration, Color*)>(0x004383C0); | |
static auto& hud_msg = addr_as_ref<void(const char* text, int, int duration, const Color*)>(0x004383C0); |
@@ -414,6 +414,7 @@ namespace rf | |||
static auto& entity_fire_init_bones = addr_as_ref<bool(EntityFireInfo *efi, Object *objp)>(0x0042EB20); | |||
static auto& entity_is_swimming = addr_as_ref<bool(Entity* ep)>(0x0042A0A0); | |||
static auto& entity_is_falling = addr_as_ref<bool(Entity* ep)>(0x0042A020); | |||
static auto& entity_is_flying = addr_as_ref<bool(Entity* ep)>(0x0042A060); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static auto& entity_is_flying = addr_as_ref<bool(Entity* ep)>(0x0042A060); | |
static auto& entity_is_flying = addr_as_ref<bool(const Entity* ep)>(0x0042A060); |
@@ -229,8 +230,15 @@ FunHook<void(rf::Player*)> render_reticle_hook{ | |||
ConsoleCommand2 spectate_cmd{ | |||
"spectate", | |||
[](std::optional<std::string> player_name) { | |||
if (!(rf::level.flags & rf::LEVEL_LOADED)) { | |||
rf::console::output("No level loaded!", nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rf::console::output("No level loaded!", nullptr); | |
rf::console::print("No level loaded!"); |
if (!rf::is_multi) { | ||
rf::console::output("Spectate mode is only supported in multiplayer game!", nullptr); | ||
// in single player, just enter free look mode | ||
rf::console::output("Camera mode set to free look. Use `camera1` to return to first person.", nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rf::console::output("Camera mode set to free look. Use `camera1` to return to first person.", nullptr); | |
rf::console::print("Camera mode set to free look. Use `camera1` to return to first person."); |
@@ -104,6 +107,59 @@ FunHook<void()> verify_level_cmd_hook{ | |||
} | |||
}; | |||
|
|||
void handle_camera_command(FunHook<void()>& hook) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void handle_camera_command(FunHook<void()>& hook) | |
void handle_camera_command(const FunHook<void()>& hook) |
} | ||
|
||
if (rf::is_multi) { | ||
rf::console::print("That command can't be used in multiplayer."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command?
const rf::CameraMode current_mode = rf::camera_get_mode(*rf::local_player->cam); | ||
|
||
std::string mode_text = (current_mode == rf::CAMERA_FIRST_PERSON) ? "first person" | ||
: (current_mode == rf::CAMERA_THIRD_PERSON) ? "third person" | ||
: (current_mode == rf::CAMERA_FREELOOK) ? "free look" | ||
: "unknown"; | ||
|
||
std::string helper_text = | ||
(current_mode == rf::CAMERA_FIRST_PERSON) ? "" : " Use `camera1` to return to first person."; | ||
|
||
rf::console::print("Camera mode set to {}.{}", mode_text, helper_text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much ternary imo. Potential rewrite:
const rf::CameraMode current_mode = rf::camera_get_mode(*rf::local_player->cam); | |
std::string mode_text = (current_mode == rf::CAMERA_FIRST_PERSON) ? "first person" | |
: (current_mode == rf::CAMERA_THIRD_PERSON) ? "third person" | |
: (current_mode == rf::CAMERA_FREELOOK) ? "free look" | |
: "unknown"; | |
std::string helper_text = | |
(current_mode == rf::CAMERA_FIRST_PERSON) ? "" : " Use `camera1` to return to first person."; | |
rf::console::print("Camera mode set to {}.{}", mode_text, helper_text); | |
std::string_view camera_mode_to_string_view(const rf::CameraMode mode) { | |
switch (mode) { | |
switch rf::CAMERA_FIRST_PERSON: return std::string_view{"first person"}; | |
switch rf::CAMERA_FREELOOK: return std::string_view{"free look"}; | |
switch rf::CAMERA_THIRD_PERSON: return std::string_view{"third person"}; | |
default: return std::string_view{"unknown camera mode"}; | |
} | |
} | |
const std::string_view mode_text = camera_mode_to_string_view(mode); | |
if (mode == rf::CAMERA_FIRST_PERSON) { | |
rf::console::print("Your camera mode was set to {}", mode_text); | |
} else { | |
rf::console::print("Your camera mode was set to {}. Use `camera1` to return to first person", mode_text); | |
} |
This PR:
spectate
set the camera to free look (same ascamera2
) when issued in single player (as opposed to just kicking back an error)camera1
,camera2
,camera3
, andheehoo
builtin cheat commands. In the case ofheehoo
, this is displayed usinghud_msg
just likevivalahelvig
andbighugmug
. For thecameraX
commands, the help text is printed to the console so that when a player wants to go back to first person, they'll know how.Resolves #206