-
Notifications
You must be signed in to change notification settings - Fork 7
/
autopilot.bgt
216 lines (214 loc) · 4.62 KB
/
autopilot.bgt
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
bool autopiloting=false;
bool usingblades;
//return codes for apCheckMove():
/*
0 = player is close to pit
1 = player can move normally
2 = player is within range of enemy
4 = player must use evade blade to jump pit and blade
3 = player is close to blades
5 = player is near boulder
*/
timer useswordtimer;
timer itemtimerr;
int checker;
bool isAttacking=false;
void autopilotStart() {
autopiloting=true;
itemtimerr.restart();
while(true) {
sounds.update_listener_1d(playerposition);
boss.fire.volume=-6;
if(level==5) {
boss.move();
if(playerposition==boss.pos-1||playerposition==boss.pos+1||playerposition==boss.pos||playerposition==boss.pos+2) {using=1;
if(useswordtimer.elapsed>=80) {
useswordtimer.restart();
shootsword();
}
}
else {
if(playerposition>boss.pos) move(2);
if(playerposition<boss.pos) move(1);
}
}
if(level!=5) {
apWork();
for(uint x=0; x<boulder.length(); x++) {
if(playerposition>boulder[x].pos-25) boulder[x].moveControl(1);
}
for(uint x=0; x<blades.length(); x++) {
if((playerposition==blades[x].position-1)&&!avoiding&&evades>0) useevadeblades();
blades[x].workIt();
}
if(itemtimerr.elapsed>=5000) {
itemtimerr.restart();
int doIt=random(1,1);
if(doIt==1) {
isItemFalling=true;
catch();
}}
for(uint x=0; x<enemy.length(); x++) {
if(!enemy[x].isDead) {
if(playerposition<enemy[x].pos-25&&playerposition>enemy[x].pos+25) enemy[x].voice.stop();
if(playerposition>enemy[x].pos-25&&playerposition<enemy[x].pos+25) enemy[x].voice.play_looped();
if(playerposition>enemy[x].pos-15&&playerposition<enemy[x].pos+15) enemy[x].move();
}
if(enemy[x].dieseq==1) {
if(!enemy[x].diesound.playing) {
enemy[x].dieseq=0;
if(level==3||level==9) enemy[x].dropwater.play();
else enemy[x].drop.play();
}
}
}
}
if(playerhealth<=0) {
dieStopSounds();
iamdead.play_wait();
lives--;
if(lives<=0) {
sound diecomp;
music.stop();
diecomp.load("sounds/health0conv.ogg");
diecomp.play();
while(diecomp.playing) {if(key_pressed(KEY_SPACE)||key_pressed(KEY_RETURN)) {diecomp.stop();}}
menu();
}
if(lives>0) {
voice.speak_interrupt_wait("you lost a life!");
voice.speak_wait("level "+level);
levelDesc();
playerhealth=250;
playerposition=0;
initAfterLevels();
}
}
if(playerhealth<=50) usepotion();
if(key_pressed(KEY_H)) voice.speak_interrupt("Health: "+playerhealth+", armor: "+armor);
if(key_pressed(KEY_ESCAPE)) {
autopiloting=false;
break;
}
wait(8);
}
}
void apWork() {
switch(apCheckMove()) {
case 1:
if(!isAttacking) move(1);
break;
case 2:
if(useswordtimer.elapsed>=70) {
useswordtimer.restart();
isAttacking=true;
shootsword();
}
break;
case 0:
apJump();
break;
case 4:
useevadeblades();
apJump();
break;
case 5:
apJump();
break;
case 6:
if(useswordtimer.elapsed>=70) {
useswordtimer.restart();
isAttacking=true;
shootsword();
}
}
}
int apCheckMove() {
for(uint x=0; x<pit.length(); x++) {
if(playerposition==pit[x].position-2) {
for(uint x=0; x<blades.length(); x++) {
if(playerposition>blades[x].position-4&&playerposition<=blades[x].position+4) return 4;
else return 0;
}
}}
for(uint x=0; x<boulder.length(); x++) {
if(playerposition==boulder[x].pos-3) return 5;
}
for(uint x=0; x<enemy.length(); x++) {
if(enemy[x].pos<=playerposition+swordrange&&enemy[x].pos>playerposition-swordrange) {
if(enemy[x].strength>=armor+5) using=2;
else using=1;
return 2;
}
if(enemy[x].pos<playerposition&&enemy[x].pos>0) {
if(enemy[x].pos>playerposition-15) return 6;
if(enemy[x].pos<playerposition-15) return 7;
}}
return 1;
}
void apJump() {
for(uint x=0; x<boulder.length(); x++) {
boulder[x].moveControl(1);
}
if(chavoid) usingblades=true;
if(!chavoid) {
if(avoiding) usingblades=true;
if(!avoiding) usingblades=false;
}
jump.play();
jumping=true;
intheair.restart();
while(jumping) {
for(uint x=0; x<boulder.length(); x++) {
boulder[x].moveControl(1);
}
for(uint x=0; x<blades.length(); x++) {
if(playerposition==blades[x].position-1) {
jumping=false;
int x=random(0,step.length()-1);
step[x].stop();
step[x].play();
intheair.restart();
break;
}
if(playerposition==blades[x].position&&usingblades==true&&!chavoid) {
breakblade.stream("sounds/bladeoff.wav");
breakblade.play();
avoiding=false;
}
if(playerposition==blades[x].position&&!usingblades) {
dieStopSounds();
dieblades.play_wait();
lives--;
if(lives<=0)
{
music.stop();
sound conv;
conv.load("sounds/bladedie.ogg");
conv.play();
while(conv.playing) {
if(key_pressed(KEY_SPACE)||key_pressed(KEY_RETURN)) conv.stop();
}
menu();
}
if(lives>0) {
voice.speak_interrupt_wait("you lost a life!");
voice.speak_wait("level "+level);
levelDesc();
playerhealth=250;
playerposition=0;
initAfterLevels();
}
break;}
blades[x].workIt();
}
positions();
wait(240);
playerposition++;
if(intheair.elapsed>=1000) {jumping=false;
int x=random(0,step.length()-1);
step[x].stop();
step[x].play();
}
}
}