-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathbl2tools.py
60 lines (46 loc) · 1.59 KB
/
bl2tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import unrealsdk
def get_player_controller():
"""
Get the current WillowPlayerController Object.
:return: WillowPlayerController
"""
return unrealsdk.GetEngine().GamePlayers[0].Actor
def get_obj_path_name(uobject: unrealsdk.UObject):
"""
Get the full correct name of the provided object.
:param uobject: UObject
:return: String of the Path Name
"""
if uobject:
return uobject.PathName(uobject)
else:
return "None"
def console_command(command: str, write_to_log: bool = False):
"""
Executes a normal console command
:param command: String, the command to execute.
:param write_to_log: Bool, write to Log
:return: None
"""
get_player_controller().ConsoleCommand(command, write_to_log)
def obj_is_in_class(uobject: unrealsdk.UObject, uclass: str):
"""
Compares the given Objects class with the given class.
:param uobject: UObject
:param uclass: String, the Class to compare with
:return: Bool, whether it's in the Class.
"""
return bool(uobject.Class == unrealsdk.FindClass(uclass))
def get_weapon_holding():
"""
Get the weapon the WillowPlayerPawn is currently holding.
:return: WillowWeapon
"""
return unrealsdk.GetEngine().GamePlayers[0].Actor.Pawn.Weapon
def get_world_info():
return unrealsdk.GetEngine().GetCurrentWorldInfo()
def feedback(title: str, text: str, duration: float):
pc = get_player_controller()
if pc is not None:
hud = pc.GetHUDMovie()
hud.AddTrainingText(text, title, duration, (), "", False, 0, pc.PlayerReplicationInfo, True)