2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 proc: game_check_monster_eating
18 set [monster_tid], [rst_result]
20 jmp game_do_die_monster
23 endp: game_check_monster_eating
26 ; check if we can slide left or right while flying
28 ; 'game_fan_dx_v' will be set to 0 if prof not slides
29 proc: game_do_fans_flyslide
31 ; game_fan_dx_v is correct here
32 ; check if we can move to the corresponding side
37 jne .noslide, FTILE_EMPTY
38 ; ok, we can slide, do that
50 jgt .fanslide, [.f], 0
53 add [pos_x], [game_fan_dx_v]
59 set [game_fan_dx_v], 0 ; clear 'sliding' flag
61 endp: game_do_fans_flyslide
64 ; will not return if 'falling' mode activated
66 local: .umb_act ; umbrella activated?
67 local: .prof_fall_count ; # of tiles before prof hits the ground
68 locals: .sy, .type, .tid, .tmp
71 set [.prof_fall_count], 0
73 jeq .nowcheat, [key_walk_cheat], 0
78 jeq .really_falling, FTILE_EMPTY
80 bsr game_check_monster_eating
82 jne game_do_door_exit, 0
86 ;jeq .fall_loop, [key_walk_cheat], 0
89 add [.prof_fall_count], 1 ; one more tile
91 jlt .noumb, [prof_item], 1 ; no items -- no umbrella
92 get [prof_item], item_id
93 jne .noumb, ITEM_UMBRELLA
94 jne .noumb, [.prof_fall_count], 4 ; open only at 4th tile
95 ; don't activate umbrella if prof is about to land
97 jne .noumb, FTILE_EMPTY
99 rst FRST_PLAY_SOUND, SND_UMBRELLA
100 set [.umb_act], 1 ; 'umbrella activated' flag
101 set [prof_dir], PDIR_FACING
102 jeq .noturn, [spr_num], PSPR_FACING
103 ; turn and open umbrella
104 set [spr_num], PSPR_TURNING
108 set [spr_dir], DIR_LEFT
109 set [spr_num], PSPR_FACING
128 set [spr_dir], DIR_LEFT
146 jeq .fastfall, [.umb_act], 0
147 ; umbrella active, fall slowly
151 jlt .slowfall_loop, [pos_ty], 10
155 ; no umbrella, fall fast
166 bsr prof_fix_position
171 ; are we out of level?
172 set [.sy], [map_height]
174 jge .out_of_level, [pos_y], [.sy]
177 jeq .nofan, [.umb_act], 0
179 jeq .nofan, [game_fan_dx_v], 0
180 bsr game_do_fans_flyslide
181 bsr prof_fix_position
183 ;add [.prof_fall_count], 1 ; one more tile
184 jne .fancheck_again, [game_fan_dx_v], 0
188 jeq .fall_loop, FTILE_EMPTY
190 jne .quit_cheat, [key_fall_cheat], 0
191 ; check 'special' tiles if umbrella wasn't used
192 jeq .checkbricks, [.umb_act], 0
193 ; close and hide umbrella
204 set [spr_num], PSPR_FACING
207 set [prof_dir], PDIR_FACING
208 set [spr_num], PSPR_FACING
209 set [spr_dir], DIR_LEFT
212 jmp game_facing_loop_w2f
215 ; check 'special' tiles
216 mgf [pos_x], [pos_y], [.type]
217 jeq .bounce, [.type], FTILE_BOUNCE
218 ; prof dies when falls 5 or more tiles
219 jge .dead, [.prof_fall_count], 5
220 ; prof is alive, process specials
221 bsr game_check_monster_eating
223 jeq .glass, [.type], FTILE_GLASS
224 jeq .ice, [.type], FTILE_ICE
230 jne game_do_door_exit, 0
231 jeq game_facing_loop_w2f, [spr_num], PSPR_FACING
232 jmp game_lr_stand_loop
236 jlt .nospecials, [.prof_fall_count], 2 ; get out if glass should not be broken
238 rst FRST_PLAY_SOUND, SND_GLASS
239 new entry_bdis, [.tid]
240 set pos_x, [pos_x], [.tid]
241 add 1, [pos_y], [.tmp]
242 set pos_y, [.tmp], [.tid]
248 set [.prof_fall_count], 0
251 ; landed on bounce pad
253 ; bounce animation: down and up
254 rst FRST_PLAY_SOUND, SND_BOUNCE
255 new entry_bstat, [.tid]
256 set pos_x, [pos_x], [.tid]
257 set pos_y, [pos_y], [.tid]
265 jeq .nospecials, [spr_num], PSPR_FACING
267 set [spr_num], PSPR_JUMPING
270 jle .bouncejump, [.prof_fall_count], 1
277 bsr prof_fix_position
280 sub [.prof_fall_count], 1
296 bsr prof_fix_position
298 ; here we can't jump, do turning
300 bsr prof_turn_to_player
303 mul [prof_dir], -1 ; opposite direction
305 jne .bounce_full_turn, 0
306 ; stay facing the player
307 set [prof_dir], PDIR_FACING
315 jne .nospecials, [spr_num], PSPR_STANDING
318 jmp game_check_do_slide_move
321 set [monster_tid], -666
322 jmp game_do_die_fall ; never returns
323 ; prof falls out of level
325 set [.sy], [map_height]
327 jge .out_dead, [pos_y], [.sy]
329 jeq .fastfall_x01, [.umb_act], 0
330 ; umbrella active, fall slowly
334 jlt .slowfall_loop_x01, [pos_ty], 10
338 ; no umbrella, fall fast
349 bsr prof_fix_position
353 set [game_state], GAME_STATE_DEAD
354 jmp game_wait_and_restart
355 endp: game_check_fall