-
Notifications
You must be signed in to change notification settings - Fork 859
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor of Player Wanted Level (#3070)
- Loading branch information
Showing
9 changed files
with
123 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include "backend/command.hpp" | ||
#include "backend/looped_command.hpp" | ||
#include "backend/looped/looped.hpp" | ||
#include "pointers.hpp" | ||
|
||
namespace big | ||
{ | ||
bool user_updated_wanted_level = false; | ||
|
||
class clear_wanted : command | ||
{ | ||
using command::command; | ||
|
||
virtual void execute(const command_arguments&, const std::shared_ptr<command_context> ctx) override | ||
{ | ||
// If we're never wanted... don't bother since there is no wanted level to clear anyway (this button won't even be shown if never_wanted is enabled) | ||
if (g.self.never_wanted) | ||
return; | ||
|
||
// Clear current wanted level | ||
g_local_player->m_player_info->m_wanted_level = 0; | ||
g_local_player->m_player_info->m_is_wanted = false; | ||
|
||
// Keep the lock if it's on, but reset the wanted level | ||
g.self.wanted_level = 0; | ||
} | ||
}; | ||
|
||
clear_wanted g_clear_wanted("clearwanted", "CLEAR_WANTED_LEVEL", "CLEAR_WANTED_LEVEL_DESC_SELF", 0); | ||
|
||
class never_wanted : looped_command | ||
{ | ||
using looped_command::looped_command; | ||
|
||
virtual void on_tick() override | ||
{ | ||
// Clear current wanted level | ||
g_local_player->m_player_info->m_wanted_level = 0; | ||
g_local_player->m_player_info->m_is_wanted = false; | ||
|
||
// Since we're hiding the force wanted checkbox and wanted slider, we don't need to do anything else | ||
} | ||
virtual void on_disable() override | ||
{ | ||
// If we turn off never wanted, be sure to disable force wanted to restore to a "default" setting | ||
g.self.force_wanted_level = false; | ||
} | ||
}; | ||
|
||
never_wanted g_never_wanted("neverwanted", "NEVER_WANTED", "NEVER_WANTED", g.self.never_wanted); | ||
|
||
void looped::self_wanted() | ||
{ | ||
// Don't do anything if we're supposed to be never wanted (this slider won't be shown if never_wanted is enabled) | ||
if (g.self.never_wanted) | ||
return; | ||
|
||
if (g_local_player && g_local_player->m_player_info) | ||
{ | ||
// We only want the wanted level to update when the player changed it via the ImGui slider | ||
if (user_updated_wanted_level) | ||
{ | ||
g_local_player->m_player_info->m_wanted_level = g.self.wanted_level; | ||
|
||
if (g.self.wanted_level == 0) | ||
g_local_player->m_player_info->m_is_wanted = false; | ||
else | ||
g_local_player->m_player_info->m_is_wanted = true; | ||
|
||
// I don't know if ImGui resets this every tick, let's assume it doesn't | ||
user_updated_wanted_level = false; | ||
return; | ||
} | ||
|
||
// Otherwise, if we're locking the wanted level, then just keep it consistently at what the player set | ||
if (g.self.force_wanted_level) | ||
{ | ||
g_local_player->m_player_info->m_wanted_level = g.self.wanted_level; | ||
|
||
if (g.self.wanted_level == 0) | ||
g_local_player->m_player_info->m_is_wanted = false; | ||
else | ||
g_local_player->m_player_info->m_is_wanted = true; | ||
} | ||
|
||
if (!user_updated_wanted_level && !g.self.force_wanted_level) | ||
{ | ||
// If the player hasn't updated the wanted level and we're not locking, then YimMenu should update its own slider value to reflect the actual in-game wanted level since it may have changed | ||
g.self.wanted_level = g_local_player->m_player_info->m_wanted_level; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters