forked from ScriptB3ast/razor-enhanced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskill_Snooping.py
80 lines (69 loc) · 3.09 KB
/
skill_Snooping.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def PlayerWalk( direction ):
'''
Moves the player in the specified direction
'''
playerPosition = Player.Position
if Player.Direction == direction:
Player.Walk( direction )
else:
Player.Walk( direction )
Player.Walk( direction )
return
def FollowMobile( mobile, maxDistanceToMobile = 2, startPlayerStuckTimer = False ):
'''
Uses the X and Y coordinates of the animal and player to follow the animal around the map
Returns True if player is not stuck, False if player is stuck
'''
mobilePosition = mobile.Position
playerPosition = Player.Position
directionToWalk = ''
if mobilePosition.X > playerPosition.X and mobilePosition.Y > playerPosition.Y:
directionToWalk = 'Down'
if mobilePosition.X < playerPosition.X and mobilePosition.Y > playerPosition.Y:
directionToWalk = 'Left'
if mobilePosition.X > playerPosition.X and mobilePosition.Y < playerPosition.Y:
directionToWalk = 'Right'
if mobilePosition.X < playerPosition.X and mobilePosition.Y < playerPosition.Y:
directionToWalk = 'Up'
if mobilePosition.X > playerPosition.X and mobilePosition.Y == playerPosition.Y:
directionToWalk = 'East'
if mobilePosition.X < playerPosition.X and mobilePosition.Y == playerPosition.Y:
directionToWalk = 'West'
if mobilePosition.X == playerPosition.X and mobilePosition.Y > playerPosition.Y:
directionToWalk = 'South'
if mobilePosition.X == playerPosition.X and mobilePosition.Y < playerPosition.Y:
directionToWalk = 'North'
if startPlayerStuckTimer:
Timer.Create( 'playerStuckTimer', 5000 )
playerPosition = Player.Position
PlayerWalk( directionToWalk )
newPlayerPosition = Player.Position
if playerPosition == newPlayerPosition and not Timer.Check( 'playerStuckTimer' ):
# Player has been stuck in the same position for a while, try to find them a way out of the stuck position
if Player.Direction == 'Up':
for i in range ( 5 ):
Player.Walk( 'Down' )
elif Player.Direction == 'Down':
for i in range( 5 ):
Player.Walk( 'Up' )
elif Player.Direction == 'Right':
for i in range( 5 ):
Player.Walk( 'Left' )
elif Player.Direction == 'Left':
for i in range( 5 ):
Player.Walk( 'Right' )
Timer.Create( 'playerStuckTimer', 5000 )
elif playerPosition != newPlayerPosition:
Timer.Create( 'playerStuckTimer', 5000 )
if Player.DistanceTo( mobile ) > maxDistanceToMobile:
# This pause may need further tuning
# Don't want to create a ton of infinite calls if the player is stuck, but also don't want to not be able to catch up to animals
Misc.Pause( 100 )
FollowMobile( mobile, maxDistanceToMobile )
return True
snoopTarget = Target.PromptTarget( 'Select whom to snoop' )
snoopTarget = Mobiles.FindBySerial( snoopTarget )
backpack = snoopTarget.Backpack
if Player.DistanceTo( snoopTarget ) > 1:
FollowMobile( snoopTarget, 1, True )
Items.UseItem( backpack )