2023-03-31 21:10:52 +02:00
|
|
|
from win32api import GetAsyncKeyState
|
|
|
|
|
2023-03-31 21:58:07 +02:00
|
|
|
from hack import Hack
|
2023-04-04 11:14:10 +02:00
|
|
|
from utils import errors_unload
|
2023-03-31 21:58:07 +02:00
|
|
|
|
2023-03-31 21:10:52 +02:00
|
|
|
|
|
|
|
class Fov(Hack):
|
2023-04-01 16:11:56 +02:00
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
2023-03-31 21:10:52 +02:00
|
|
|
|
|
|
|
self.__fov = None
|
|
|
|
self.__factor = 5
|
2023-04-03 02:40:57 +02:00
|
|
|
self.__default_fov = 90
|
2023-03-31 21:10:52 +02:00
|
|
|
|
|
|
|
def fov(self) -> None:
|
|
|
|
# Aliases
|
|
|
|
mem = self.pm
|
|
|
|
offset = self.offsets
|
|
|
|
|
|
|
|
# Get module addresses
|
|
|
|
client = self.find_module("client")
|
|
|
|
|
|
|
|
# Get local player
|
2023-04-03 02:40:57 +02:00
|
|
|
self.__local_player = self.find_uint(client, offset["dwLocalPlayer"])
|
2023-04-03 02:50:16 +02:00
|
|
|
local_player = self.__local_player
|
2023-03-31 21:10:52 +02:00
|
|
|
|
|
|
|
# Get FOV
|
|
|
|
self.__fov = self.find_uint(local_player, offset["m_iDefaultFOV"])
|
|
|
|
|
|
|
|
def cheat():
|
2023-05-05 16:04:06 +02:00
|
|
|
if self.__fov is None:
|
2023-03-31 21:10:52 +02:00
|
|
|
raise ValueError("FOV isn't defined.")
|
|
|
|
fov = self.__fov
|
|
|
|
|
|
|
|
# Reset FOV
|
|
|
|
if GetAsyncKeyState(self.vmap["END"]):
|
|
|
|
self.__fov = 90
|
|
|
|
|
|
|
|
# Increase FOV
|
2023-04-01 15:22:27 +02:00
|
|
|
elif GetAsyncKeyState(self.vmap["PAGE_DOWN"]) and self.__fov < 130:
|
2023-03-31 21:10:52 +02:00
|
|
|
self.__fov += self.__factor
|
|
|
|
|
|
|
|
# Decrease FOV
|
2023-04-01 15:22:27 +02:00
|
|
|
elif GetAsyncKeyState(self.vmap["PAGE_UP"]) and self.__fov > 50:
|
2023-03-31 21:10:52 +02:00
|
|
|
self.__fov -= self.__factor
|
|
|
|
|
|
|
|
# If modified
|
|
|
|
if fov != self.__fov:
|
2023-04-01 16:20:46 +02:00
|
|
|
# Override the FOV value
|
2023-05-05 16:04:06 +02:00
|
|
|
mem.write_int(local_player + offset["m_iDefaultFOV"], self.__fov)
|
2023-03-31 21:10:52 +02:00
|
|
|
|
|
|
|
self.hack_loop(cheat)
|
2023-04-03 02:40:57 +02:00
|
|
|
|
|
|
|
def fov_unload(self):
|
|
|
|
# Aliases
|
|
|
|
mem = self.pm
|
|
|
|
offset = self.offsets
|
2023-04-04 11:14:10 +02:00
|
|
|
try:
|
|
|
|
local_player = self.__local_player
|
|
|
|
except errors_unload():
|
|
|
|
# No modification has been done
|
|
|
|
return
|
2023-04-03 02:40:57 +02:00
|
|
|
|
|
|
|
# Reset to default value if changed
|
|
|
|
if self.__fov not in [None, self.__default_fov]:
|
2023-05-05 16:04:06 +02:00
|
|
|
mem.write_int(local_player + offset["m_iDefaultFOV"], self.__default_fov)
|