Skip to content

Commit fbf60c2

Browse files
committed
Refactor modules ( BREAKING CHANGES )
1. rename cleo -> addition 2. move call_function, call_method, free_library, load_library, get_proc_address into memory modules 3. move test_cheat into common module 4. Update all examples
1 parent b03bb2c commit fbf60c2

File tree

20 files changed

+753
-755
lines changed

20 files changed

+753
-755
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
from typing import Tuple
2+
import _addition
3+
4+
def get_car_handle(pVeh :int) -> int:
5+
'''Get vehicle handle from pointer'''
6+
7+
return _addition.get_car_handle(pVeh)
8+
9+
def get_car_pointer(hveh :int) -> int:
10+
'''Get vehicle pointer from handle'''
11+
12+
return _addition.get_car_pointer(hveh)
13+
14+
def get_char_handle(pPed :int) -> int:
15+
'''Get char handle from pointer'''
16+
17+
return _addition.get_char_handle(pPed)
18+
19+
def get_char_pointer(hped :int) -> int:
20+
'''Get char pointer from handle'''
21+
22+
return _addition.get_char_pointer(hped)
23+
24+
def get_closest_ped() -> int:
25+
'''Returns the closest ped to player'''
26+
27+
return _addition.get_closest_ped()
28+
29+
def get_closest_vehicle() -> int:
30+
'''Returns the closest vehicle to player'''
31+
32+
return _addition.get_closest_vehicle()
33+
34+
def get_largest_gangid_in_zone() -> int:
35+
'''Returns the gang id of the largest gang in player's current zone'''
36+
37+
return _addition.get_largest_gangid_in_zone()
38+
39+
def get_object_handle(pObj :int) -> int:
40+
'''Get object handle from pointer'''
41+
42+
return _addition.get_object_handle(pObj)
43+
44+
def get_object_pointer(hObj :int) -> int:
45+
'''Get object pointer from handle'''
46+
47+
return _addition.get_object_pointer(hObj)
48+
49+
def get_player_targeted_char() -> int:
50+
'''Get the char player is targetting with a weapon'''
51+
52+
return _addition.get_player_targeted_char()
53+
54+
def get_target_marker_coords() -> Tuple[float, float, float]:
55+
'''Get coordinates of target marker. Returns -1, -1, -1 on failure'''
56+
57+
return _addition.get_target_marker_coords()
58+
59+
def get_vehicle_current_gear(hveh :int) -> int:
60+
'''Get the current gear of the vehicle'''
61+
62+
return _addition.get_vehicle_current_gear(hveh)
63+
64+
def get_vehicle_model_from_name(name :str) -> int:
65+
'''Get vehicle model from name'''
66+
67+
return _addition.get_vehicle_model_from_name(name)
68+
69+
def get_vehicle_model_name(model :int) -> str:
70+
'''Get vehicle name from model'''
71+
72+
return _addition.get_vehicle_model_name(model)
73+
74+
def get_vehicle_number_of_gears(hveh :int) -> int:
75+
'''Get number of total vehicle gears'''
76+
77+
return _addition.get_vehicle_number_of_gears(hveh)
78+
79+
def is_on_cutscene() -> bool:
80+
'''Is a cutscene being played'''
81+
82+
return _addition.is_on_cutscene()
83+
84+
def is_on_mission() -> bool:
85+
'''Is a mission running'''
86+
87+
return _addition.is_on_mission()
88+
89+
def is_vehicle_engine_on(hveh :int) -> bool:
90+
'''Is vehicle engine is turned on'''
91+
92+
return _addition.is_vehicle_engine_on(hveh)
93+
94+
def is_vehicle_siren_on(hveh: int) -> bool:
95+
'''Is vehicle siren is on'''
96+
97+
return _addition.is_vehicle_siren_on(hveh)
98+
99+
def set_vehicle_engine_state(hveh :int, state: bool) -> None:
100+
'''Sets the engine state of the vehicle'''
101+
102+
_addition.set_vehicle_engine_state(hveh, state)
103+

runtime/PyLoader/libstd/cleo.py

Lines changed: 0 additions & 133 deletions
This file was deleted.

runtime/PyLoader/libstd/common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ def wait(time_ms: int = 0):
2525
'''Freezes the script for specified amount of time. Must be used inside each loop'''
2626

2727
_common.wait(time_ms)
28+
29+
def test_cheat(cheat :str) -> bool:
30+
'''Checks whether the particular character sequence was pressed'''
31+
32+
return _common.test_cheat(cheat)

runtime/PyLoader/libstd/events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def on_ped_destroy(hped :int) -> None:
2929
pass
3030

3131
def on_obj_create(hobj :int) -> None:
32-
'''Called after a new object is created'''
32+
'''Called after a new object is created. Doesn't work with SilentPatch'''
3333
pass
3434

3535
def on_obj_render(hobj :int) -> None:
36-
'''Called when a object is being rendered'''
36+
'''Called when a object is being rendered. Doesn't work with SilentPatch'''
3737
pass
3838

3939
def on_obj_destroy(hobj :int) -> None:
40-
'''Called before a object is destroyed'''
40+
'''Called before a object is destroyed. Doesn't work with SilentPatch'''
4141
pass
4242

4343
def on_game_restart() -> None:
Binary file not shown.
7.25 KB
Binary file not shown.

runtime/PyLoader/libstd/game_sa/_cppinterface.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from abc import ABCMeta, abstractmethod, abstractproperty, abstractstaticmethod
99
from typing import Tuple, Final, Generic, TypeVar
10-
from libstd.memory import read_memory, write_memory, read_float, write_float
11-
from libstd.cleo import call_function, call_method
10+
from libstd.memory import read_memory, write_memory, read_float, write_float, call_function, call_method
1211
from enum import Enum
1312
import ctypes
1413

runtime/PyLoader/libstd/game_sa/clock.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from typing import List
2-
import cleo
1+
import memory
32
from libstd.game_sa._cppinterface import mem_handler
43

54
class CClock:
@@ -21,36 +20,36 @@ class CClock:
2120

2221
# Returns number of minutes to specified hour & minute.
2322
def GetGameClockMinutesUntil(self, hours :int, minutes :int):
24-
return cleo.call_function(0x52CEB0, 2, 0, hours, minutes)
23+
return memory.call_function(0x52CEB0, 2, 0, hours, minutes)
2524

2625
# Returns true current hour is in range of two specified hours.
2726
def GetIsTimeInRange(self, hourA :int, hourB :int):
28-
return cleo.call_function(0x52CEE0, 2, 0, hourA, hourB)
27+
return memory.call_function(0x52CEE0, 2, 0, hourA, hourB)
2928

3029
def Initialise(self, milisecondsPerGameMinute :int):
31-
cleo.call_function(0x52CD90, 1, 0, milisecondsPerGameMinute)
30+
memory.call_function(0x52CD90, 1, 0, milisecondsPerGameMinute)
3231

3332
# Normalizes game clock
3433
# For example hour of 24 means new day and hour 1.
3534
def NormaliseGameClock(self):
36-
cleo.call_function(0x52CDE0, 1, 0)
35+
memory.call_function(0x52CDE0, 1, 0)
3736

3837
# Sets new day
3938
# Directions (0 = one day backwards, 1 = one day forwards)
4039
def OffsetClockByADay(self, timeDirection :int):
41-
cleo.call_function(0x52D0B0, 1, 0, timeDirection)
40+
memory.call_function(0x52D0B0, 1, 0, timeDirection)
4241

4342
def RestoreClock(self):
44-
cleo.call_function(0x52D070, 0, 0)
43+
memory.call_function(0x52D070, 0, 0)
4544

4645
def SetGameClock(self, hours, minutes, day):
47-
cleo.call_function(0x52D150, 3, 0, hours, minutes, day)
46+
memory.call_function(0x52D150, 3, 0, hours, minutes, day)
4847

4948
def StoreClock(self):
50-
cleo.call_function(0x52D020, 0, 0)
49+
memory.call_function(0x52D020, 0, 0)
5150

5251
def Update(self):
53-
cleo.call_function(0x52CF10, 0, 0)
52+
memory.call_function(0x52CF10, 0, 0)
5453

5554
# Create instance
5655
CClock = CClock()

0 commit comments

Comments
 (0)