| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- function enemy_move_and_collide()
- {
- var _y_spd_total = (y_spd + y_spd_kb) * global.time_scale;
- var _x_spd_total = (x_spd + x_spd_kb) * global.time_scale;
-
- if place_meeting(x, y + _y_spd_total, oParentSolid)
- {
- while !place_meeting(x, y + sign(_y_spd_total), oParentSolid)
- y += sign(_y_spd_total);
-
- _y_spd_total = 0;
- y_spd = 0;
- y_spd_kb = 0;
- }
- y += _y_spd_total;
- if place_meeting(x + _x_spd_total, y, oParentSolid)
- {
- while !place_meeting(x + sign(_x_spd_total), y, oParentSolid)
- x += sign(_x_spd_total);
-
- _x_spd_total = 0;
- x_spd = 0;
- x_spd_kb = 0;
- }
- x += _x_spd_total;
- }
- function enemy_check_hitstun()
- {
- if hitstun_timer > 0
- {
- hitstun_timer -= global.time_scale;
- x_spd_kb = lerp(x_spd_kb, 0, 0.1);
- y_spd_kb = lerp(y_spd_kb, 0, 0.1);
-
- x_spd = 0;
- y_spd = 0;
- }
- else
- {
- x_spd_kb = 0;
- y_spd_kb = 0;
- }
- }
- function enemy_get_hit(_damage, _kb_x, _kb_y)
- {
- hp -= _damage;
-
- if can_hitstun
- hitstun_timer = hitstun_max;
- x_spd_kb = _kb_x * kb_factor;
- y_spd_kb = _kb_y * kb_factor;
- image_blend = c_blue;
- alarm[0] = 10;
- if hp <= 0
- {
- is_dead = true;
- instance_destroy(); // animation
- }
- }
- function enemy_crawl_ai()
- {
- var _wall_ahead = place_meeting(x + facing, y, oParentSolid);
- var _hazard_ahead = place_meeting(x + facing * abs(sprite_width) / 2, y, oParentHazard);
- var _ledge_ahead = !place_meeting(x + facing * abs(sprite_width), y + 1, oParentSolid);
-
- if _wall_ahead || _ledge_ahead || _hazard_ahead
- facing *= -1;
-
- x_spd = facing * walk_spd;
- y_spd += global.g;
- }
|