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 set [.umb_act], 1 ; 'umbrella activated' flag
100 set [prof_dir], PDIR_FACING
101 jeq .noturn, [spr_num], PSPR_FACING
102 ; turn and open umbrella
103 set [spr_num], PSPR_TURNING
107 set [spr_dir], DIR_LEFT
108 set [spr_num], PSPR_FACING
127 set [spr_dir], DIR_LEFT
145 jeq .fastfall, [.umb_act], 0
146 ; umbrella active, fall slowly
150 jlt .slowfall_loop, [pos_ty], 10
154 ; no umbrella, fall fast
165 bsr prof_fix_position
170 ; are we out of level?
171 set [.sy], [map_height]
173 jge .out_of_level, [pos_y], [.sy]
176 jeq .nofan, [.umb_act], 0
178 jeq .nofan, [game_fan_dx_v], 0
179 bsr game_do_fans_flyslide
180 bsr prof_fix_position
182 ;add [.prof_fall_count], 1 ; one more tile
183 jne .fancheck_again, [game_fan_dx_v], 0
187 jeq .fall_loop, FTILE_EMPTY
189 jne .quit_cheat, [key_fall_cheat], 0
190 ; check 'special' tiles if umbrella wasn't used
191 jeq .checkbricks, [.umb_act], 0
192 ; close and hide umbrella
203 set [spr_num], PSPR_FACING
206 set [prof_dir], PDIR_FACING
207 set [spr_num], PSPR_FACING
208 set [spr_dir], DIR_LEFT
211 jmp game_facing_loop_w2f
214 ; check 'special' tiles
215 mgf [pos_x], [pos_y], [.type]
216 jeq .bounce, [.type], FTILE_BOUNCE
217 ; prof dies when falls 5 or more tiles
218 jge .dead, [.prof_fall_count], 5
219 ; prof is alive, process specials
220 bsr game_check_monster_eating
222 jeq .glass, [.type], FTILE_GLASS
223 jeq .ice, [.type], FTILE_ICE
229 jne game_do_door_exit, 0
230 jeq game_facing_loop_w2f, [spr_num], PSPR_FACING
231 jmp game_lr_stand_loop
235 jlt .nospecials, [.prof_fall_count], 2 ; get out if glass should not be broken
237 new entry_bdis, [.tid]
238 set pos_x, [pos_x], [.tid]
239 add 1, [pos_y], [.tmp]
240 set pos_y, [.tmp], [.tid]
246 set [.prof_fall_count], 0
249 ; landed on bounce pad
251 ; bounce animation: down and up
252 new entry_bstat, [.tid]
253 set pos_x, [pos_x], [.tid]
254 set pos_y, [pos_y], [.tid]
262 jeq .nospecials, [spr_num], PSPR_FACING
264 set [spr_num], PSPR_JUMPING
267 jle .bouncejump, [.prof_fall_count], 1
274 bsr prof_fix_position
277 sub [.prof_fall_count], 1
292 bsr prof_fix_position
294 ; here we can't jump, do turning
296 bsr prof_turn_to_player
299 mul [prof_dir], -1 ; opposite direction
301 jne .bounce_full_turn, 0
302 ; stay facing the player
303 set [prof_dir], PDIR_FACING
311 jne .nospecials, [spr_num], PSPR_STANDING
314 jmp game_check_do_slide_move
317 set [monster_tid], -666
318 jmp game_do_die_fall ; never returns
319 ; prof falls out of level
321 set [.sy], [map_height]
323 jge .out_dead, [pos_y], [.sy]
325 jeq .fastfall_x01, [.umb_act], 0
326 ; umbrella active, fall slowly
330 jlt .slowfall_loop_x01, [pos_ty], 10
334 ; no umbrella, fall fast
345 bsr prof_fix_position
349 set [game_state], GAME_STATE_DEAD
350 jmp game_wait_and_restart
351 endp: game_check_fall