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

What's an effective way of finding the correct 3 pixels? #27

Closed
DNBRMK3 opened this issue Oct 27, 2021 · 12 comments
Closed

What's an effective way of finding the correct 3 pixels? #27

DNBRMK3 opened this issue Oct 27, 2021 · 12 comments
Assignees
Labels
question Further information is requested

Comments

@DNBRMK3
Copy link

DNBRMK3 commented Oct 27, 2021

Hi,

Not sure if this is the right place to put this im not a git hub user.

I've been playing around to get 1440p to work with your code... (I'm no developer). All I did was increase the pixel values by 33.333% which works for all the weapons apart from the p2020 or the R99. What's an effective way of finding the correct 3 pixels?

Happy to share with you the changes if you want to post a working 1440p version.

DNBR

@mgsweet mgsweet added the question Further information is requested label Oct 28, 2021
@mgsweet mgsweet self-assigned this Oct 28, 2021
@mgsweet
Copy link
Owner

mgsweet commented Oct 28, 2021

What pixels did I pick?

The detection logic is very simple. It chooses three special pixels of the weapon and checks whether the colour there is white or not (white = true).

Screen Shot 2021-10-28 at 10 03 52 PM

How do I get all the pixels?

Before, I used a tool built by myself on the /debug folder. But I recommend you to use pmeter to do so. It can show the position and colour of where your mouse is pointing after some configuration.

Step:

  • Take screenshots for the weapons you want to detect.
  • Get three special points and put them into my code (e.g. d66dbd4).
  • Check whether it works or not~

I also provide some voice tips to tell which weapon you are holding for debugging. Uncomment them to use.

Contributing

You are welcome! You can submit a pull request and I will find a way to help users config their resolution later.

@mgsweet mgsweet changed the title 1440p AHK What's an effective way of finding the correct 3 pixels? Oct 30, 2021
@VStorm001
Copy link
Contributor

I tried to get pixels myself, but it didn't seem to work.
Is there a limit on pixel positions?

; heavy weapon
global CAR_PIXELS := [1572, 973, true, 1649, 982, false, 1658, 992, true]

; heavy weapon pattern
global CAR_PATTERN := LoadPattern("CAR.txt")

; then check the weapon type
else if (CheckWeapon (CAR_PIXELS)) {
current_weapon_type := CAR_WEAPON_TYPE
current_pattern := CAR_PATTERN
}

@mgsweet
Copy link
Owner

mgsweet commented Nov 4, 2021

@VStorm001 Check the diff I made in the commit history. Check those commits for which I added support to new weapons. Or you can just wait till the next update. Feeling tired after going back home during the workday and will update the script this weekend.

@leafwalktuffy
Copy link

I tried to get pixels myself, but it didn't seem to work. Is there a limit on pixel positions?

; heavy weapon global CAR_PIXELS := [1572, 973, true, 1649, 982, false, 1658, 992, true]

; heavy weapon pattern global CAR_PATTERN := LoadPattern("CAR.txt")

; then check the weapon type else if (CheckWeapon (CAR_PIXELS)) { current_weapon_type := CAR_WEAPON_TYPE current_pattern := CAR_PATTERN }

CAR_PIXELS := [1605, 970, true, 1586, 973, true, 1605, 971, true]
These three pixels are useful

@VStorm001
Copy link
Contributor

VStorm001 commented Nov 4, 2021

CAR_PIXELS := [1605, 970, true, 1586, 973, true, 1605, 971, true] These three pixels are useful

It still doesn't work.
Is the problem in weapon color?

@mgsweet
Copy link
Owner

mgsweet commented Nov 5, 2021

@VStorm001 Check the latest commit: d66dbd4

@VStorm001
Copy link
Contributor

VStorm001 commented Nov 5, 2021

Check the latest commit: d66dbd4

@mgsweet It still doesn't work.

@mgsweet
Copy link
Owner

mgsweet commented Nov 5, 2021

@VStorm001 Really? Are u using the latest version of the script?

@mgsweet
Copy link
Owner

mgsweet commented Nov 6, 2021

Here, I would also record the way how to generate <resolution>.ini file for the latest version.

First, use some silly script to map the 1080p pixels to the one you want, for example: 1080 / 3 * 4 = 1440, so:

func main() {
	str1 := `havoc_terbocharger = "1621,1006"
devotion_terbocharger = "1650,1007"`
	tmp := strings.Split(str1, "\n")

	fmt.Println(len(tmp))

	for _, v := range tmp {
		t1 := strings.Split(v, " = ")
		res := t1[0] + " = \""
		t2 := strings.Split(t1[1][1: len(t1[1]) - 1], ",")
		for i, v := range t2 {
			t3, _ := strconv.ParseInt(v, 10, 64)
			if t3 > 1 {
				t3 = t3 * 4 / 3
			}
			res += strconv.FormatInt(t3,10)
			if i != len(t2) - 1 {
				res += ","
			}
		}
		res += "\""
		fmt.Println(res)
	}
}

Yes, I know the names of the variables above are shit. But... for silly code....

Then, run the game and do some checks. For those which cannot work, use the pixel capture approach I mention above to do some more modifications.

@VStorm001
Copy link
Contributor

func main() {
	str1 := `havoc_terbocharger = "1621,1006"
devotion_terbocharger = "1650,1007"`
	tmp := strings.Split(str1, "\n")

	fmt.Println(len(tmp))

	for _, v := range tmp {
		t1 := strings.Split(v, " = ")
		res := t1[0] + " = \""
		t2 := strings.Split(t1[1][1: len(t1[1]) - 1], ",")
		for i, v := range t2 {
			t3, _ := strconv.ParseInt(v, 10, 64)
			if t3 > 1 {
				t3 = t3 * 4 / 3
			}
			res += strconv.FormatInt(t3,10)
			if i != len(t2) - 1 {
				res += ","
			}
		}
		res += "\""
		fmt.Println(res)
	}
}

I tried to output 1280x720, but some weapons didn't work

@mgsweet
Copy link
Owner

mgsweet commented Nov 8, 2021

I tried to output 1280x720, but some weapons didn't work

For those not working, you still have to do it manually.
image

@mgsweet
Copy link
Owner

mgsweet commented Nov 8, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants