| 1 | depth = -y; | 
    
    
        | 2 | if (global.player_sprites == "steamworkslava") | 
    
    
        | 3 | { | 
    
    
        | 4 |     palette_index = 3; | 
    
    
        | 5 |     shader_on = true; | 
    
    
        | 6 | } | 
    
    
        | 7 | else if (global.player_sprites == "normal") | 
    
    
        | 8 | { | 
    
    
        | 9 |     shader_on = false; | 
    
    
        | 10 | } | 
    
    
        | 11 | if (obj_pl.yprevious != obj_pl.y || obj_pl.xprevious != obj_pl.x) | 
    
    
        | 12 | { | 
    
    
        | 13 |     npc_move_current = clamp(npc_move_current + 1, 0, npc_move_delay_max); | 
    
    
        | 14 |     x_new[npc_move_current] = obj_pl.x; | 
    
    
        | 15 |     y_new[npc_move_current] = obj_pl.y; | 
    
    
        | 16 |     dir_new[npc_move_current] = obj_pl.direction; | 
    
    
        | 17 |     if (abs(obj_pl.yprevious - obj_pl.y) >= 5 || abs(obj_pl.xprevious - obj_pl.x) >= 5) | 
    
    
        | 18 |         sprinting_new[npc_move_current] = true; | 
    
    
        | 19 |     else | 
    
    
        | 20 |         sprinting_new[npc_move_current] = false; | 
    
    
        | 21 | } | 
    
    
        | 22 | if (npc_move_current >= npc_move_delay_max) | 
    
    
        | 23 | { | 
    
    
        | 24 |     npc_move_current = clamp(npc_move_current - 1, 0, npc_move_delay_max); | 
    
    
        | 25 |     x = x_new[1]; | 
    
    
        | 26 |     y = y_new[1]; | 
    
    
        | 27 |     follower_idle = false; | 
    
    
        | 28 |     switch (dir_new[1]) | 
    
    
        | 29 |     { | 
    
    
        | 30 |         case 0: | 
    
    
        | 31 |             if (sprinting_new[1] == true) | 
    
    
        | 32 |                 sprite_index = right_sprite_run; | 
    
    
        | 33 |             else | 
    
    
        | 34 |                 sprite_index = right_sprite; | 
    
    
        | 35 |             break; | 
    
    
        | 36 |         case 90: | 
    
    
        | 37 |             if (sprinting_new[1] == true) | 
    
    
        | 38 |                 sprite_index = up_sprite_run; | 
    
    
        | 39 |             else | 
    
    
        | 40 |                 sprite_index = up_sprite; | 
    
    
        | 41 |             break; | 
    
    
        | 42 |         case 180: | 
    
    
        | 43 |             if (sprinting_new[1] == true) | 
    
    
        | 44 |                 sprite_index = left_sprite_run; | 
    
    
        | 45 |             else | 
    
    
        | 46 |                 sprite_index = left_sprite; | 
    
    
        | 47 |             break; | 
    
    
        | 48 |         case 270: | 
    
    
        | 49 |             if (sprinting_new[1] == true) | 
    
    
        | 50 |                 sprite_index = down_sprite_run; | 
    
    
        | 51 |             else | 
    
    
        | 52 |                 sprite_index = down_sprite; | 
    
    
        | 53 |             break; | 
    
    
        | 54 |     } | 
    
    
        | 55 |     image_speed = 0.2; | 
    
    
        | 56 |     if (sprinting_new[1] == true) | 
    
    
        | 57 |         image_speed = 0.3; | 
    
    
        | 58 |     for (var i = 0; i < npc_move_delay_max; i++) | 
    
    
        | 59 |     { | 
    
    
        | 60 |         x_new[i] = x_new[i + 1]; | 
    
    
        | 61 |         y_new[i] = y_new[i + 1]; | 
    
    
        | 62 |         dir_new[i] = dir_new[i + 1]; | 
    
    
        | 63 |         sprinting_new[i] = sprinting_new[i + 1]; | 
    
    
        | 64 |     } | 
    
    
        | 65 | } | 
    
    
        | 66 | else | 
    
    
        | 67 | { | 
    
    
        | 68 |     follower_idle = true; | 
    
    
        | 69 |     switch (dir_new[1]) | 
    
    
        | 70 |     { | 
    
    
        | 71 |         case 0: | 
    
    
        | 72 |             sprite_index = right_sprite_idle; | 
    
    
        | 73 |             break; | 
    
    
        | 74 |         case 90: | 
    
    
        | 75 |             sprite_index = up_sprite_idle; | 
    
    
        | 76 |             break; | 
    
    
        | 77 |         case 180: | 
    
    
        | 78 |             sprite_index = left_sprite_idle; | 
    
    
        | 79 |             break; | 
    
    
        | 80 |         case 270: | 
    
    
        | 81 |             sprite_index = down_sprite_idle; | 
    
    
        | 82 |             break; | 
    
    
        | 83 |     } | 
    
    
        | 84 | } | 
    
    
        | 85 | if (npc_reset == true) | 
    
    
        | 86 | { | 
    
    
        | 87 |     event_perform(ev_create, 0); | 
    
    
        | 88 |     var player_distance = point_distance(x, y, obj_pl.x, obj_pl.y) / 10; | 
    
    
        | 89 |     player_distance = clamp(player_distance, 1, 999); | 
    
    
        | 90 |     for (var i = npc_move_delay_max; i > 0; i--) | 
    
    
        | 91 |     { | 
    
    
        | 92 |         x_new[i] = x + (sign(obj_pl.x - x) * (i * player_distance)); | 
    
    
        | 93 |         y_new[i] = y + (sign(obj_pl.y - y) * (i * player_distance)); | 
    
    
        | 94 |         if (abs(point_distance(x, y, x_new[npc_move_delay_max], y)) > abs(point_distance(x, y, x, y_new[npc_move_delay_max]))) | 
    
    
        | 95 |         { | 
    
    
        | 96 |             if (obj_pl.x > x) | 
    
    
        | 97 |                 dir_new[i] = 0; | 
    
    
        | 98 |             else | 
    
    
        | 99 |                 dir_new[i] = 180; | 
    
    
        | 100 |         } | 
    
    
        | 101 |         else if (obj_pl.y > y) | 
    
    
        | 102 |         { | 
    
    
        | 103 |             dir_new[i] = 270; | 
    
    
        | 104 |         } | 
    
    
        | 105 |         else | 
    
    
        | 106 |         { | 
    
    
        | 107 |             dir_new[i] = 90; | 
    
    
        | 108 |         } | 
    
    
        | 109 |         npc_move_current += 1; | 
    
    
        | 110 |     } | 
    
    
        | 111 |     npc_reset = false; | 
    
    
        | 112 | } | 
    
    
        | 113 | if (follower_idle == true) | 
    
    
        | 114 | { | 
    
    
        | 115 |     if (instance_exists(obj_dialogue) && is_talking == true) | 
    
    
        | 116 |     { | 
    
    
        | 117 |         if (obj_dialogue.cutoff == string_length(obj_dialogue.message[obj_dialogue.message_current])) | 
    
    
        | 118 |         { | 
    
    
        | 119 |             image_speed = 0; | 
    
    
        | 120 |             image_index = 0; | 
    
    
        | 121 |         } | 
    
    
        | 122 |         else | 
    
    
        | 123 |         { | 
    
    
        | 124 |             image_speed = 0.2; | 
    
    
        | 125 |         } | 
    
    
        | 126 |     } | 
    
    
        | 127 |     else | 
    
    
        | 128 |     { | 
    
    
        | 129 |         image_speed = 0; | 
    
    
        | 130 |         image_index = 0; | 
    
    
        | 131 |         is_talking = false; | 
    
    
        | 132 |     } | 
    
    
        | 133 | } |