This repository has been archived on 2023-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
csh/cheats/fov.py

67 lines
1.9 KiB
Python
Raw Normal View History

2023-03-31 21:10:52 +02:00
from win32api import GetAsyncKeyState
2023-03-31 21:58:07 +02:00
from hack import Hack
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:
# 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
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)