if (!instance_exists(obj_plat_player)) { scr_flower_despwn(); exit; } if (global.pause_plat) exit; onscreen = scr_onscreen(id); if (onscreen && state == 0) { state = 1; vspeed = -6; sprite_index = spr_enemy_book_simple_freefall; image_speed = 0.5; } if (state == 1) { vspeed += 0.25; scr_plat_depthcast(); if (vspeed > -2) state = 2; } if (state == 2) { var _yoff = sin(timer / 20) * 2; var _p = 910; if (instance_exists(_p)) aim = point_direction(x, y, _p.x, _p.y - 5); var _dir = aim; timer++; direction = _dir; image_xscale = sign(-lengthdir_x(1, aim)) * 2; if (lengthdir_y(1, aim) > 0.5) { image_index = (timer / 2) % 2; sprite_index = spr_enemy_book_simple_freefall; speed = scr_movetowards(speed, 7, 0.4); } else { y += _yoff; image_speed = 0.5; sprite_index = spr_enemy_book_simple; speed = scr_movetowards(speed, onscreen ? 3 : 7, 0.4); } if (point_distance(0, 0, (x - _p.x) * 0.75, y - _p.y) <= 200) state_set(3); } if (state == 3) { var _p = 910; if (instance_exists(_p)) { aim = point_direction(x, y, _p.x, _p.y - 15) + random_range(-10, 10); dist = point_distance(x, y, _p.x, _p.y - 15); } var _dir = aim; sprite_index = spr_enemy_book_simple_freefall; if (timer >= 16) { image_index = 2; } else { image_speed = fallspeed / 8; if (image_index >= 2) image_index -= 2; } fallspeed = scr_movetowards(fallspeed, 4, 0.2); y += fallspeed; if (timer != 16 || lengthdir_y(1, aim) <= 0) timer++; if (dist > 200) timer += 3; if (timer < 20) speed *= 0.8; if (timer == 16) { var _this = id; with (obj_plat_enm_book_simple) { if (state == 3 && timer >= 12 && timer < 16) timer = 12; } } if (timer >= 20) { state_set(4); image_speed = 0; var _xdir = lengthdir_x(1, aim); if (_xdir > 0) image_xscale = -abs(image_xscale); else if (_xdir < 0) image_xscale = abs(image_xscale); sprite_index = spr_enemy_book_simple; flash_hurt(16777215); snd_play(snd_wing, 0.6, 1.3); } } if (state == 4) { var _dir = aim; var _duration = 40; var _prog = timer / _duration; if (substate == 0) { speed += 1.5; image_index = clamp01(speed / 6) * 2; if (speed >= 15) substate = 1; } else if (substate == 1) { speed -= 0.75; if (speed <= 0) { speed = 0; state_set(2); fallspeed = 1; } else if (speed < 4) { image_index = 0; } else if (speed < 8) { image_index = 3; } } y++; direction = _dir; } if (state == 10) { }