Skip to content

Commit

Permalink
Added 3-Pt Shortening
Browse files Browse the repository at this point in the history
  • Loading branch information
elanjcoop committed Mar 17, 2023
1 parent ad72728 commit be57338
Show file tree
Hide file tree
Showing 13 changed files with 419 additions and 292 deletions.
6 changes: 0 additions & 6 deletions Elan's Engine.CT
@@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="45">
<CheatEntries>
<CheatEntry>
<ID>4</ID>
<Description>"No description"</Description>
<VariableType>Byte</VariableType>
<Address>nba2k14.exe+11DD541</Address>
</CheatEntry>
<CheatEntry>
<ID>11</ID>
<Description>"Time"</Description>
Expand Down
67 changes: 67 additions & 0 deletions Shot Chance Research.CT
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="45">
<CheatEntries>
<CheatEntry>
<ID>0</ID>
<Description>"No description"</Description>
<VariableType>Float</VariableType>
<Address>nba2k14.exe+FBCAC4</Address>
</CheatEntry>
<CheatEntry>
<ID>1</ID>
<Description>"No description"</Description>
<ShowAsSigned>0</ShowAsSigned>
<VariableType>Float</VariableType>
<Address>nba2k14.exe+ADB328</Address>
</CheatEntry>
<CheatEntry>
<ID>3</ID>
<Description>"No description"</Description>
<VariableType>Float</VariableType>
<Address>nba2k14.exe+1A16298</Address>
</CheatEntry>
<CheatEntry>
<ID>4</ID>
<Description>"No description"</Description>
<VariableType>Float</VariableType>
<Address>nba2k14.exe+1A1640C</Address>
</CheatEntry>
<CheatEntry>
<ID>5</ID>
<Description>"No description"</Description>
<VariableType>Float</VariableType>
<Address>nba2k14.exe+F0CA28</Address>
</CheatEntry>
<CheatEntry>
<ID>8</ID>
<Description>"No description"</Description>
<VariableType>Byte</VariableType>
<Address>nba2k14.exe+19EE3B4</Address>
</CheatEntry>
<CheatEntry>
<ID>9</ID>
<Description>"No description"</Description>
<VariableType>Byte</VariableType>
<Address>nba2k14.exe+19EE3E8</Address>
</CheatEntry>
<CheatEntry>
<ID>11</ID>
<Description>"No description"</Description>
<VariableType>Byte</VariableType>
<Address>nba2k14.exe+1A09A14</Address>
</CheatEntry>
<CheatEntry>
<ID>12</ID>
<Description>"No description"</Description>
<VariableType>Byte</VariableType>
<Address>nba2k14.exe+1A165C8</Address>
</CheatEntry>
<CheatEntry>
<ID>13</ID>
<Description>"No description"</Description>
<VariableType>Byte</VariableType>
<Address>nba2k14.exe+1A165D8</Address>
</CheatEntry>
</CheatEntries>
<UserdefinedSymbols/>
</CheatTable>
178 changes: 89 additions & 89 deletions build/main/Analysis-00.toc

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions build/main/EXE-00.toc

Large diffs are not rendered by default.

Binary file modified build/main/Elan's Mod.pkg
Binary file not shown.
166 changes: 83 additions & 83 deletions build/main/PKG-00.toc

Large diffs are not rendered by default.

Binary file modified build/main/PYZ-00.pyz
Binary file not shown.
Binary file modified build/main/base_library.zip
Binary file not shown.
Binary file modified build/main/main.pkg
Binary file not shown.
8 changes: 4 additions & 4 deletions build/main/warn-main.txt
Expand Up @@ -15,19 +15,19 @@ IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
tracking down the missing module yourself. Thanks!

missing module named _posixshmem - imported by multiprocessing.resource_tracker (conditional), multiprocessing.shared_memory (conditional)
missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named org - imported by copy (optional)
missing module named 'org.python' - imported by pickle (optional), xml.sax (delayed, conditional)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named _posixsubprocess - imported by subprocess (optional), multiprocessing.util (delayed)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named pep517 - imported by importlib.metadata (delayed)
missing module named pwd - imported by shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional), posixpath (delayed, conditional), netrc (delayed, conditional), getpass (delayed)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional), netrc (delayed, conditional), getpass (delayed)
missing module named grp - imported by shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional)
missing module named posix - imported by shutil (conditional), importlib._bootstrap_external (conditional), os (conditional, optional)
missing module named posix - imported by os (conditional, optional), shutil (conditional), importlib._bootstrap_external (conditional)
missing module named resource - imported by posix (top-level)
missing module named org - imported by pickle (optional)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named fcntl - imported by subprocess (optional)
Expand Down
12 changes: 6 additions & 6 deletions build/main/xref-main.html
Expand Up @@ -291,7 +291,7 @@ <h1>modulegraph cross reference for main.py, pyi_rth_inspect.py, pyi_rth_multipr
<a target="code" href="" type="text/plain"><tt>'org.python'</tt></a>
<span class="moduletype">MissingModule</span> <div class="import">
imported by:
<a href="#copy">copy</a>
<a href="#pickle">pickle</a>
&#8226; <a href="#xml.sax">xml.sax</a>

</div>
Expand Down Expand Up @@ -2785,8 +2785,8 @@ <h1>modulegraph cross reference for main.py, pyi_rth_inspect.py, pyi_rth_multipr
<a target="code" href="///C:/Users/coope/AppData/Local/Programs/Python/Python310/lib/copy.py" type="text/plain"><tt>copy</tt></a>
<span class="moduletype">SourceModule</span> <div class="import">
imports:
<a href="#'org.python'">'org.python'</a>
&#8226; <a href="#copyreg">copyreg</a>
<a href="#copyreg">copyreg</a>
&#8226; <a href="#org">org</a>
&#8226; <a href="#types">types</a>
&#8226; <a href="#weakref">weakref</a>

Expand Down Expand Up @@ -8299,7 +8299,7 @@ <h1>modulegraph cross reference for main.py, pyi_rth_inspect.py, pyi_rth_multipr
<a target="code" href="" type="text/plain"><tt>org</tt></a>
<span class="moduletype">MissingModule</span> <div class="import">
imported by:
<a href="#pickle">pickle</a>
<a href="#copy">copy</a>

</div>

Expand Down Expand Up @@ -8462,14 +8462,14 @@ <h1>modulegraph cross reference for main.py, pyi_rth_inspect.py, pyi_rth_multipr
<a target="code" href="///C:/Users/coope/AppData/Local/Programs/Python/Python310/lib/pickle.py" type="text/plain"><tt>pickle</tt></a>
<span class="moduletype">SourceModule</span> <div class="import">
imports:
<a href="#_compat_pickle">_compat_pickle</a>
<a href="#'org.python'">'org.python'</a>
&#8226; <a href="#_compat_pickle">_compat_pickle</a>
&#8226; <a href="#_pickle">_pickle</a>
&#8226; <a href="#codecs">codecs</a>
&#8226; <a href="#copyreg">copyreg</a>
&#8226; <a href="#functools">functools</a>
&#8226; <a href="#io">io</a>
&#8226; <a href="#itertools">itertools</a>
&#8226; <a href="#org">org</a>
&#8226; <a href="#pprint">pprint</a>
&#8226; <a href="#re">re</a>
&#8226; <a href="#struct">struct</a>
Expand Down
Binary file modified dist/Elan's Mod.exe
Binary file not shown.
106 changes: 86 additions & 20 deletions main.py
Expand Up @@ -43,6 +43,7 @@
AWAY_SCORE_ADDRESS = 0x19E260C
SHOT_LENGTH_ADDRESS = 0x1A16290
THREE_POINTER_VALUE_ADDRESS = 0x19EE944
TWO_POINTER_VALUE_ADDRESS = 0x19EE948
INTERNAL_GAME_YEAR_ADDRESS = 0xF32918
HOME_GAME_FOULS_ADDRESS = 0x19E2540
AWAY_GAME_FOULS_ADDRESS = 0x19E29C4
Expand All @@ -56,6 +57,7 @@
target_shot_clock_reset = 14.000001
target_target_score = 5
target_overtime_deadline = 3600.0
shortened_three_point_length = 601.98

prev_home_off_reb_count, prev_away_off_reb_count = 0, 0

Expand All @@ -75,6 +77,7 @@
halves_enabled = False
g_league_free_throw_rule_enabled = False
threes_disabled = False
shorten_threes_enabled = False

def set_shot_clock_full(input_shot_clock_full):
try:
Expand Down Expand Up @@ -120,6 +123,19 @@ def set_overtime_deadline(input_overtime_deadline):
else:
target_overtime_deadline = 3600.0

def set_shortened_three_length(input_shortened_three_length):
try:
input_shortened_three_length = float(input_shortened_three_length)
except:
input_shortened_three_length = 23.75
global shortened_three_point_length
if input_shortened_three_length > 0.0 and input_shortened_three_length < 99.0:
shortened_three_point_length = input_shortened_three_length * 30.48
print("Shortened three length: ", shortened_three_point_length, sep = '')
else:
shortened_three_point_length = 723.9
print("Shortened three length: ", shortened_three_point_length, sep = '')

def check_overtime_started(mem, module):
if mem.read_short(module + PERIOD_ADDRESS) == 5:
global has_overtime, overtime_start_home_score, overtime_start_away_score
Expand Down Expand Up @@ -161,6 +177,12 @@ def threes_off(mem, module):
if mem.read_short(module + THREE_POINTER_VALUE_ADDRESS) == 3:
mem.write_short(module + THREE_POINTER_VALUE_ADDRESS, 2)

def shorten_threes(mem, module):
if mem.read_float(module + SHOT_LENGTH_ADDRESS) > shortened_three_point_length:
mem.write_short(module + TWO_POINTER_VALUE_ADDRESS, 3)
else:
mem.write_short(module + TWO_POINTER_VALUE_ADDRESS, 2)


#If first free throw goes in, there is a bug.
def check_target_score_reached(mem, module):
Expand Down Expand Up @@ -219,6 +241,12 @@ def start_mod():
elif mem.read_float(module + SHOT_CLOCK_ADDRESS) == OFFICIAL_RULES_SHOT_CLOCK:
mem.write_float(module + SHOT_CLOCK_ADDRESS, target_shot_clock_full)
#print("Shot clock reset with ", round(mem.read_float(module + PERIOD_TIME_LEFT), 2), " remaining in Q", mem.read_short(module + PERIOD_ADDRESS), sep = '')
if shorten_threes_enabled:
shorten_threes(mem, module)
else:
if mem.read_short(module + TWO_POINTER_VALUE_ADDRESS) != 2:
mem.write_short(module + TWO_POINTER_VALUE_ADDRESS, 2)
print("Reverted 3-Pt Shortening.")
if ten_second_violation_enabled:
if mem.read_float(module + BACKCOURT_TIME_LEFT_ADDRESS) == OFFICIAL_BACKCOURT_TIME:
mem.write_float(module + BACKCOURT_TIME_LEFT_ADDRESS, 10.0)
Expand Down Expand Up @@ -249,7 +277,7 @@ def window():
app = QApplication(sys.argv)
win = QMainWindow()

win.setGeometry(1200, 300, 350, 500)
win.setGeometry(1200, 300, 350, 630)
win.setWindowTitle("Elan's Mod")
win.setWindowIcon(QIcon("ja.jpg"))
def resource_path(relative_path):
Expand All @@ -264,49 +292,57 @@ def resource_path(relative_path):

lbl_please_open_game = QtWidgets.QLabel(win)
lbl_please_open_game.setText("")
lbl_please_open_game.move(50, 25)
lbl_please_open_game.move(40, 25)
lbl_please_open_game.setLineWidth(100)

lbl_shot_clock = QtWidgets.QLabel(win)
lbl_shot_clock.setText("Shot Clock: ")
lbl_shot_clock.move(50, 50)
lbl_shot_clock.move(40, 50)

lbl_reset_shot_clock = QtWidgets.QLabel(win)
lbl_reset_shot_clock.setText("Reset Shot Clock:")
lbl_reset_shot_clock.move(50, 90)
lbl_reset_shot_clock.move(40, 90)

lbl_ten_second_violation = QtWidgets.QLabel(win)
lbl_ten_second_violation.setText("10 Second Backcourt Violation")
lbl_ten_second_violation.move(50,130)
lbl_ten_second_violation.move(40,130)

lbl_enable_target_score = QtWidgets.QLabel(win)
lbl_enable_target_score.setText("Target Score")
lbl_enable_target_score.move(50,170)
lbl_enable_target_score.move(40,170)

lbl_target_score = QtWidgets.QLabel(win)
lbl_target_score.setText("OT Target Score:")
lbl_target_score.move(50, 210)
lbl_target_score.move(40, 210)

lbl_overtime_deadline = QtWidgets.QLabel(win)
lbl_overtime_deadline.setText("OT Deadline (minutes):")
lbl_overtime_deadline.adjustSize()
lbl_overtime_deadline.move(50, 250)
lbl_overtime_deadline.move(40, 250)

lbl_enable_halves = QtWidgets.QLabel(win)
lbl_enable_halves.setText("Two Halves")
lbl_enable_halves.move(50, 290)
lbl_enable_halves.move(40, 290)

lbl_gleague_ft_rule = QtWidgets.QLabel(win)
lbl_gleague_ft_rule.setText("G-League FT Rule")
lbl_gleague_ft_rule.move(50, 330)
lbl_gleague_ft_rule.move(40, 330)

lbl_internal_game_year = QtWidgets.QLabel(win)
lbl_internal_game_year.setText("Internal Game Year")
lbl_internal_game_year.move(50, 370)
lbl_internal_game_year.move(40, 370)

lbl_disable_threes = QtWidgets.QLabel(win)
lbl_disable_threes.setText("Disable Three Pointers?")
lbl_disable_threes.move(50, 410)
lbl_disable_threes.setText("Disable 3-Pointers?")
lbl_disable_threes.move(40, 410)

lbl_enable_shortened_threes = QtWidgets.QLabel(win)
lbl_enable_shortened_threes.setText("Shorten 3-Pointers?")
lbl_enable_shortened_threes.move(40, 450)

lbl_shortened_threes = QtWidgets.QLabel(win)
lbl_shortened_threes.setText("3-Point length (ft):")
lbl_shortened_threes.move(40, 490)

txt_shot_clock = QtWidgets.QLineEdit(win)
txt_shot_clock.move(200, 50)
Expand Down Expand Up @@ -363,16 +399,52 @@ def enable_target_score_clicked(self):
txt_internal_game_date_year.setPlaceholderText("2013")
txt_internal_game_date_year.setText("2013")

def disable_threes(self):
global shorten_threes_enabled, threes_disabled
if checkbox_disable_threes.isChecked():
print("3s: Disabled")
threes_disabled = True
checkbox_shorten_threes.setChecked(False)
enable_shortened_threes(checkbox_shorten_threes)
checkbox_shorten_threes.setDisabled(True)
else:
print("3s: Enabled")
threes_disabled = False
checkbox_shorten_threes.setDisabled(False)

checkbox_disable_threes = QtWidgets.QCheckBox(win)
checkbox_disable_threes.setChecked(False)
checkbox_disable_threes.move(200, 410)
checkbox_disable_threes.clicked.connect(disable_threes)

def enable_shortened_threes(self):
global shorten_threes_enabled
if checkbox_shorten_threes.isChecked():
print("Shortened threes on.")
txt_shortened_threes_length.setDisabled(False)
shorten_threes_enabled = True
else:
print("Shortened threes off.")
txt_shortened_threes_length.setDisabled(True)
shorten_threes_enabled = False

checkbox_shorten_threes = QtWidgets.QCheckBox(win)
checkbox_shorten_threes.setChecked(False)
checkbox_shorten_threes.move(200, 450)
checkbox_shorten_threes.clicked.connect(enable_shortened_threes)

txt_shortened_threes_length = QtWidgets.QLineEdit(win)
txt_shortened_threes_length.move(200, 490)
txt_shortened_threes_length.setDisabled(True)
txt_shortened_threes_length.setText(str(shortened_three_point_length / 30.48))

def apply_clicked(self):
print("New values applied.")
set_shot_clock_full(txt_shot_clock.text())
set_shot_clock_reset(txt_reset_shot_clock.text())
set_target_score(txt_target_score.text())
set_overtime_deadline(txt_overtime_deadline.text())
set_shortened_three_length(txt_shortened_threes_length.text())
global ten_second_violation_enabled, halves_enabled, g_league_free_throw_rule_enabled, threes_disabled
if checkbox_enable_ten_second.isChecked():
print("Ten second backcourt enabled.")
Expand All @@ -394,12 +466,6 @@ def apply_clicked(self):
else:
print("G-League FTs: Disabled")
g_league_free_throw_rule_enabled = False
if checkbox_disable_threes.isChecked():
print("3s: Disabled")
threes_disabled = True
else:
print("3s: Enabled")
threes_disabled = False
try:
mem = Pymem("nba2k14.exe")
module = module_from_name(mem.process_handle, "nba2k14.exe").lpBaseOfDll
Expand All @@ -414,7 +480,7 @@ def apply_clicked(self):
btn_apply = QtWidgets.QPushButton(win)
btn_apply.setText("Apply")
btn_apply.clicked.connect(apply_clicked)
btn_apply.move(200, 450)
btn_apply.move(200, 530)
thread1 = QThread1()
thread1.start()

Expand Down

0 comments on commit be57338

Please sign in to comment.