-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomParkour.py
183 lines (168 loc) · 5.52 KB
/
RandomParkour.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Imports
import mcpi.minecraft as minecraft
import mcpi.block as block
import random
import time
# Get the Minecraft World Handle
mc = minecraft.Minecraft.create()
# Variables
pos = mc.player.getTilePos()
OPOS = pos
# Difficulty of the Game. 0 is Easiest, 8 is Hardest.
difficulty = 8
# Define Special Minecraft Parkour Jumps According to Difficulty
def skeppy(dis):
if difficulty == 3:
mc.setBlock(pos.x+1, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+2, pos.y-1, pos.z, block.STONE.id)
pos.x += 3
else:
if dis == 4 and OPOS.y - pos.y < 4:
mc.setBlock(pos.x+1, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+3, pos.y-2, pos.z, block.STONE.id)
pos.x += 4
pos.y -= 1
else:
mc.setBlock(pos.x+1, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+2, pos.y-1, pos.z, block.STONE.id)
pos.x += 3
def headhitter(dis):
if difficulty == 3:
mc.setBlock(pos.x, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+2, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+2, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x+3, pos.y-1, pos.z, block.STONE.id)
pos.x += 4
else:
mc.setBlock(pos.x, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+dis, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+dis, pos.y+2, pos.z, block.STONE.id)
mc.setBlock(pos.x+dis+1, pos.y-1, pos.z, block.STONE.id)
pos.x += dis+2
def neo(dis):
if difficulty == 5:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+2, pos.y+1, pos.z, block.STONE.id)
mc.setBlock(pos.x+3, pos.y-1, pos.z, block.GOLD_BLOCK.id)
pos.x += 4
elif difficulty == 6:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+2, pos.y+1, pos.z, block.STONE.id)
pos.x += 3
elif difficulty == 7:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y-1, pos.z, block.STONE.id)
if dis == 4:
dis = 3
for i in range(0,dis):
mc.setBlock(pos.x+i+2, pos.y+1, pos.z, block.STONE.id)
mc.setBlock(pos.x+i+3, pos.y-1, pos.z, block.GOLD_BLOCK.id)
pos.x += i+4
else:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y-1, pos.z, block.STONE.id)
if dis == 4:
dis = 3
for i in range(0,dis):
mc.setBlock(pos.x+i+2, pos.y+1, pos.z, block.STONE.id)
mc.setBlock(pos.x+i+3, pos.y-1, pos.z, block.STONE.id)
pos.x += i+4
def corner():
if difficulty == 5:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y+1, pos.z+1, block.STONE.id)
mc.setBlock(pos.x+2, pos.y-1, pos.z+2, block.GOLD_BLOCK.id)
pos.x += 3
pos.z += 3
elif difficulty == 6:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y+1, pos.z+1, block.STONE.id)
mc.setBlock(pos.x+2, pos.y-1, pos.z+2, block.STONE.id)
pos.x += 3
pos.z += 3
elif difficulty == 7:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y+1, pos.z+1, block.STONE.id)
mc.setBlock(pos.x+2, pos.y+1, pos.z+1, block.STONE.id)
mc.setBlock(pos.x+3, pos.y-1, pos.z+2, block.GOLD_BLOCK.id)
pos.x += 4
pos.z += 3
else:
mc.setBlock(pos.x, pos.y-1, pos.z, block.STONE.id)
mc.setBlock(pos.x+1, pos.y+1, pos.z+1, block.STONE.id)
mc.setBlock(pos.x+2, pos.y+1, pos.z+1, block.STONE.id)
mc.setBlock(pos.x+3, pos.y-1, pos.z+2, block.STONE.id)
pos.x += 4
pos.z += 3
specialjump = 0
# Parkour Course Generation
mc.setBlock(pos.x,pos.y-1,pos.z, block.GOLD_BLOCK.id)
for i in range(25):
# Parkour Generation Variables
rng = random.randint(0,50)
offsetz = 0
offsety = 0
dis = random.randint(2,3)
if difficulty > 0:
dis = random.randint(3,4)
if difficulty > 1:
offsetz = random.randint(0,1)
offsety = random.randint(0,1)
# Parkour Jump Distance
pos.x += dis
# The More Difficulty, the More Special Jumps
def jumprng(chance):
if rng < 12-chance:
mc.setBlock(pos.x, pos.y-1 + offsety, pos.z + offsetz, block.GOLD_BLOCK.id)
specialjump = 0
elif 10 <= rng <= 10+chance and difficulty > 2:
skeppy(dis)
specialjump = 1
elif 11+chance <= rng <= 11+2*chance and difficulty > 2:
headhitter(dis)
specialjump = 1
elif 12+2*chance <= rng <= 12+2*chance+round(chance/2) and difficulty > 4:
neo(dis)
specialjump = 1
elif 13+2*chance+round(chance/2) <= rng <= 12+2*chance+2*(round(chance/2)) and difficulty > 4:
corner()
specialjump = 1
else:
mc.setBlock(pos.x, pos.y-1 + offsety, pos.z + offsetz, block.STONE.id)
specialjump = 0
if difficulty < 5:
jumprng(2)
elif 5 <= difficulty <= 6:
jumprng(3)
else:
jumprng(4)
# Adds Extra Block to Impossible 4 Block 1 Up Jump
if offsety == 1 and dis == 4 and specialjump == 0:
mc.setBlock(pos.x-1, pos.y-1 + offsety, pos.z + offsetz, block.STONE.id)
pos.x += dis
mc.setBlock(pos.x,pos.y-1,pos.z, block.GOLD_BLOCK.id)
# Checkpoint Variables
spos = OPOS
prevspos = spos
# Loop for Checkpoints
while True:
# Checkpoint On Gold Block
time.sleep(0.1)
rpos = mc.player.getTilePos()
check = mc.getBlock(rpos.x,rpos.y-1,rpos.z)
if check == block.GOLD_BLOCK:
spos = rpos
if prevspos != spos:
mc.postToChat("Checkpoint!")
prevspos = spos
# Return to Last Checkpoint if Fallen
if rpos.y < OPOS.y - 4:
mc.player.setTilePos(spos.x,spos.y,spos.z)
mc.postToChat("You fell! Returing to last checkpoint.")