Deltarune (Chapter 3) script viewer

← back to main script listing

gml_GlobalScript_scr_board_enemy_hurt_state

(view raw script w/o annotations or w/e)
1
function 
scr_board_enemy_hurt_state
scr_board_enemy_hurt_state

function
scr_board_enemy_hurt_state()
{ if (hurttimer > 0) { hurttimer--; active_hitbox = false; if (hurttimer == 0 && hp != maxhp) active_hitbox = true; if (hurttimer == 9 && hp <= 0) { splash = instance_create_depth(centerx(), centery(), depth - 2, obj_board_enemydefeatsplash); splash.depth = depth - 1; global.flag[1255 sword_route_kills]++; obj_board_controller.kris_object.xp += xp_given; instance_destroy(); var a = true; if (object_index == obj_board_enemy_monster && hp == 999) a = false; if (spawnerid != -1 && i_ex(spawnerid) && a == true) { with (spawnerid) instance_destroy(); } if (drop_candy == true) { var drop_rate = 5; if (obj_board_controller.kris_object.myhealth < 8) drop_rate += 20; if (obj_board_controller.kris_object.myhealth < 3) drop_rate += 30; if (obj_board_controller.kris_object.myhealth == obj_board_controller.kris_object.maxhealth) drop_rate = 0; if (irandom(100) < drop_rate || (obj_board_controller.kris_object.monstersdefeated >= 6 && drop_rate > 0) || (obj_board_controller.kris_object.monstersdefeated >= 3 && obj_board_controller.kris_object.myhealth < 3 && drop_rate > 0)) { splash.drop_candy = true; obj_board_controller.kris_object.monstersdefeated = 0; } else { obj_board_controller.kris_object.monstersdefeated++; } } } var dontmove = false; if (object_index == obj_board_enemy_lizard && movecon == 3) dontmove = true; if (hurttimer > 6 && dontmove == false) { if (hitdir == 0) { repeat (20) { if (!place_meeting(x, y + 1, obj_board_solid)) y += 1; else break; } } if (hitdir == 1) { repeat (20) { if (!place_meeting(x + 1, y, obj_board_solid)) x += 1; else break; } } if (hitdir == 2) { repeat (20) { if (!place_meeting(x, y - 1, obj_board_solid)) y -= 1; else break; } } if (hitdir == 3) { repeat (20) { if (!place_meeting(x - 1, y, obj_board_solid)) x -= 1; else break; } } } } if (object_index == obj_board_enemy_lizard && movecon == 3) { if (x < 160) x = 160; if (x > 448) x = 448; if (y < 0) y = 0; if (y > 256) y = 256; } ...
()
2
{
3
    if (hurttimer > 0)
4
    {
5
        hurttimer--;
6
        active_hitbox = false;
7
        if (hurttimer == 0 && hp != maxhp)
8
            active_hitbox = true;
9
        if (hurttimer == 9 && hp <= 0)
10
        {
11
            splash = instance_create_depth(centerx(), centery(), depth - 2, obj_board_enemydefeatsplash);
12
            splash.depth = depth - 1;
13
            global.flag[1255 sword_route_kills]++;
14
            obj_board_controller.kris_object.xp += xp_given;
15
            instance_destroy();
16
            var a = true;
17
            if (object_index == obj_board_enemy_monster && hp == 999)
18
                a = false;
19
            if (spawnerid != -1 && i_ex(spawnerid) && a == true)
20
            {
21
                with (spawnerid)
22
                    instance_destroy();
23
            }
24
            if (drop_candy == true)
25
            {
26
                var drop_rate = 5;
27
                if (obj_board_controller.kris_object.myhealth < 8)
28
                    drop_rate += 20;
29
                if (obj_board_controller.kris_object.myhealth < 3)
30
                    drop_rate += 30;
31
                if (obj_board_controller.kris_object.myhealth == obj_board_controller.kris_object.maxhealth)
32
                    drop_rate = 0;
33
                if (irandom(100) < drop_rate || (obj_board_controller.kris_object.monstersdefeated >= 6 && drop_rate > 0) || (obj_board_controller.kris_object.monstersdefeated >= 3 && obj_board_controller.kris_object.myhealth < 3 && drop_rate > 0))
34
                {
35
                    splash.drop_candy = true;
36
                    obj_board_controller.kris_object.monstersdefeated = 0;
37
                }
38
                else
39
                {
40
                    obj_board_controller.kris_object.monstersdefeated++;
41
                }
42
            }
43
        }
44
        var dontmove = false;
45
        if (object_index == obj_board_enemy_lizard && movecon == 3)
46
            dontmove = true;
47
        if (hurttimer > 6 && dontmove == false)
48
        {
49
            if (hitdir == 0)
50
            {
51
                repeat (20)
52
                {
53
                    if (!place_meeting(x, y + 1, obj_board_solid))
54
                        y += 1;
55
                    else
56
                        break;
57
                }
58
            }
59
            if (hitdir == 1)
60
            {
61
                repeat (20)
62
                {
63
                    if (!place_meeting(x + 1, y, obj_board_solid))
64
                        x += 1;
65
                    else
66
                        break;
67
                }
68
            }
69
            if (hitdir == 2)
70
            {
71
                repeat (20)
72
                {
73
                    if (!place_meeting(x, y - 1, obj_board_solid))
74
                        y -= 1;
75
                    else
76
                        break;
77
                }
78
            }
79
            if (hitdir == 3)
80
            {
81
                repeat (20)
82
                {
83
                    if (!place_meeting(x - 1, y, obj_board_solid))
84
                        x -= 1;
85
                    else
86
                        break;
87
                }
88
            }
89
        }
90
    }
91
    if (object_index == obj_board_enemy_lizard && movecon == 3)
92
    {
93
        if (x < 160)
94
            x = 160;
95
        if (x > 448)
96
            x = 448;
97
        if (y < 0)
98
            y = 0;
99
        if (y > 256)
100
            y = 256;
101
    }
102
    else if (object_index != obj_board_enemy_silentcat)
103
    {
104
        if (x < 160)
105
            x = 160;
106
        if (x > 448)
107
            x = 448;
108
        if (y < 96)
109
            y = 96;
110
        if (y > 256)
111
            y = 256;
112
    }
113
}