Skip to content
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

[Bug]: Never Wanted doesn't work properly #3150

Closed
2 tasks done
ShinyWasabi opened this issue May 18, 2024 · 6 comments · Fixed by #3152
Closed
2 tasks done

[Bug]: Never Wanted doesn't work properly #3150

ShinyWasabi opened this issue May 18, 2024 · 6 comments · Fixed by #3152
Labels
bug Something isn't working

Comments

@ShinyWasabi
Copy link
Contributor

Describe the bug

The recent implementation of the Never Wanted feature doesn't work properly. It is inefficient in Fort Zancudo, and causes wanted level to go back and forth in some cases.

Steps To Reproduce

  1. Enable Self -> Never Wanted.
  2. Go to Fort Zancudo or play a mission that constantly sets your wanted level.

Expected Behavior

No wanted level.

Logs

cout.txt

Screenshots / Video

1

Store

Steam

Language

English

YimMenu Language

English (US)

Additional context

The purpose of the max wanted level byte patch was to prevent this issue. I think we should add it back, or directly use SET_MAX_WANTED_LEVEL native.

Build

  • I've confirmed the issue exists on the latest version of YimMenu

Coload

  • I've tested this without co-loading anything.
@ShinyWasabi ShinyWasabi added the bug Something isn't working label May 18, 2024
@gir489returns
Copy link
Contributor

This is related to the change from #3070. @rkwapisz I'm assigning this to you.

@rkwapisz
Copy link
Contributor

Thanks. I'll take a look at this.

@gir489returns
Copy link
Contributor

I suggest we hook the natives that try to set the wanted level and reject the call if never_wanted is enabled. However, this could have side effects like getting the game stuck in a loop, where it needs the player to be wanted for something like a mission.

@rkwapisz
Copy link
Contributor

rkwapisz commented May 19, 2024

I suggest we hook the natives that try to set the wanted level and reject the call if never_wanted is enabled. However, this could have side effects like getting the game stuck in a loop, where it needs the player to be wanted for something like a mission.

Thanks. I've been able to try a few things with hooking SET_PLAYER_WANTED_LEVEL.

I can confirm with the log outputs that SET_PLAYER_WANTED_LEVEL is being invoked when trespassing into Zancudo or Bolingbroke. However, even when I prevent the native from being called, the wanted level is still being modified from somewhere else. I thought maybe SET_PLAYER_WANTED_LEVEL_NO_DROP, but same thing.

Arguments are coming in correctly, so the player and wanted level checks are as expected. Yet despite the appearance of my BLOCKED SET_PLAYER_WANTED_LEVEL messages the wanted level continues to refresh consistently.

Note that increasing the player's wanted level by attacking peds does not involve SET_PLAYER_WANTED_LEVEL (this was previously unknown to me).

SET_MAX_WANTED_LEVEL to 0 helps prevent this, but the problem with this is that while we can remember what the max wanted level was before enabling never_wanted, we can't know what it SHOULD be once the player disables it. Could be some corner cases (perhaps some heists?) where the player is doing something with never_wanted at a point where the game wants to change it, but we ignore that change entirely.

void SET_PLAYER_WANTED_LEVEL(rage::scrNativeCallContext* src)
{
	const auto player = src->get_arg<Player>(0);
	const int level = src->get_arg<int>(1);

	LOG(INFO) << "SET_PLAYER_WANTED_LEVEL: " << self::id << " " << player << " " << level << " " << src->get_arg<BOOL>(2);

	// Stop the wanted level from being set in the first place by a script if g.self.never_wanted (and we're not trying to set it to 0)
	if (player == self::id && g.self.never_wanted && level > 0)
	{
		LOG(INFO) << "BLOCKED SET_PLAYER_WANTED_LEVEL: " << self::id << " " << player << " " << level << " " << src->get_arg<BOOL>(2);
		return;
	}

	PLAYER::SET_PLAYER_WANTED_LEVEL(player, level, src->get_arg<BOOL>(2));
}

@mikedrugs
Copy link

This is actually true, sometimes the wanted level goes on and off and i can see it on the cops visually trying to attack me for a second and they leave, it's not just on the fort zancudo.

@gir489returns
Copy link
Contributor

@rkwapisz Please see @ShinyWasabi's post here: #3152 (comment) as to why that occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants