Deltarune (Chapter 1) script viewer

← back to main script listing

gml_GlobalScript_scr_damage

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

function
scr_damage()
{ var debug_inv = 0; if (variable_global_exists("chemg_god_mode")) debug_inv = global.chemg_god_mode; if (global.inv < 0 && debug_inv == 0) {
scr_damage_cache();
if (target < 3) { if (global.hp[global.char[target]] <= 0) {
scr_randomtarget();
target = mytarget; with (global.charinstance[target]) { image_blend = c_white; darkify = 0; } } } chartarget = 3; tdamage = damage; if (target < 3) { tdamage = ceil(tdamage - (global.battledf[target] * 3)); chartarget = global.char[target]; if (global.charaction[target] == 10) tdamage = ceil((2 * tdamage) / 3); if (tdamage < 1) tdamage = 1; } if (!instance_exists(obj_shake)) instance_create(0, 0, obj_shake); with (global.charinstance[target]) { hurt = 1; hurttimer = 0; } hpdiff = tdamage; with (obj_dmgwriter) { if (delaytimer >= 1) killactive = 1; } doomtype = -1; with (obj_heart) dmgnoise = 1; if (target < 3) { if (global.hp[chartarget] <= 0) { doomtype = 4; global.hp[chartarget] -= round(tdamage / 4); hpdiff = round(tdamage / 4); } else { global.hp[chartarget] -= tdamage; if (global.hp[chartarget] <= 0) { hpdiff = abs(global.hp[chartarget] - (global.maxhp[chartarget] / 2)); doomtype = 4; global.hp[chartarget] = round(-global.maxhp[chartarget] / 2);
scr_dead(target);
} } dmgwriter = instance_create(global.charinstance[target].x, (global.charinstance[target].y + global.charinstance[target].myheight) - 24, obj_dmgwriter); dmgwriter.damage = hpdiff; dmgwriter.type = doomtype; } if (target == 3) { for (hpi = 0; hpi < 3; hpi += 1) { chartarget = global.char[hpi]; if (global.hp[chartarget] >= 0) { if (global.charaction[hpi] == 10) global.hp[chartarget] -= ceil(tdamage / 2); else global.hp[chartarget] -= tdamage; if (global.hp[chartarget] <= 0) global.hp[chartarget] = round(-global.maxhp[0] / 2); } } } global.inv = global.invc * 40; scr_damage_check(); gameover = 1; if (global.char[0] != 0 && global.hp[global.char[0]] > 0) gameover = 0; if (global.char[1] != 0 && global.hp[global.char[1]] > 0) gameover = 0; if (global.char[2] != 0 && global.hp[global.char[2]] > 0) gameover = 0; if (gameover == 1)
scr_gameover();
} }
()
2
{
3
    var debug_inv = 0;
4
    if (variable_global_exists("chemg_god_mode"))
5
        debug_inv = global.chemg_god_mode;
6
    if (global.inv < 0 && debug_inv == 0)
7
    {
8
        
scr_damage_cache
scr_damage_cache

function
scr_damage_cache()
{ global.damage_cache = []; for (var i = 0; i < 3; i++) global.damage_cache[array_length(global.damage_cache)] = global.hp[global.char[i]]; } function scr_damage_check() { if (!variable_global_exists("damage_cache")) global.damage_cache = []; var took_damage = false; for (var i = 0; i < array_length(global.damage_cache); i++) { var hp_cache = global.damage_cache[i]; if (global.hp[global.char[i]] < hp_cache) { took_damage = true; break; } } if (took_damage) { with (obj_event_manager) trigger_event(UnknownEnum.Value_1); } } enum UnknownEnum { Value_1 = 1 }
();
9
        if (target < 3)
10
        {
11
            if (global.hp[global.char[target]] <= 0)
12
            {
13
                
scr_randomtarget
scr_randomtarget

function
scr_randomtarget()
{ abletotarget = 1; if (global.charcantarget[0] == 0 && global.charcantarget[1] == 0 && global.charcantarget[2] == 0) abletotarget = 0; mytarget = choose(0, 1, 2); if (abletotarget == 1) { while (global.charcantarget[mytarget] == 0) mytarget = choose(0, 1, 2); } else { mytarget = 3; } global.targeted[mytarget] = 1; }
();
14
                target = mytarget;
15
                with (global.charinstance[target])
16
                {
17
                    image_blend = c_white;
18
                    darkify = 0;
19
                }
20
            }
21
        }
22
        chartarget = 3;
23
        tdamage = damage;
24
        if (target < 3)
25
        {
26
            tdamage = ceil(tdamage - (global.battledf[target] * 3));
27
            chartarget = global.char[target];
28
            if (global.charaction[target] == 10)
29
                tdamage = ceil((2 * tdamage) / 3);
30
            if (tdamage < 1)
31
                tdamage = 1;
32
        }
33
        if (!instance_exists(obj_shake))
34
            instance_create(0, 0, obj_shake);
35
        with (global.charinstance[target])
36
        {
37
            hurt = 1;
38
            hurttimer = 0;
39
        }
40
        hpdiff = tdamage;
41
        with (obj_dmgwriter)
42
        {
43
            if (delaytimer >= 1)
44
                killactive = 1;
45
        }
46
        doomtype = -1;
47
        with (obj_heart)
48
            dmgnoise = 1;
49
        if (target < 3)
50
        {
51
            if (global.hp[chartarget] <= 0)
52
            {
53
                doomtype = 4;
54
                global.hp[chartarget] -= round(tdamage / 4);
55
                hpdiff = round(tdamage / 4);
56
            }
57
            else
58
            {
59
                global.hp[chartarget] -= tdamage;
60
                if (global.hp[chartarget] <= 0)
61
                {
62
                    hpdiff = abs(global.hp[chartarget] - (global.maxhp[chartarget] / 2));
63
                    doomtype = 4;
64
                    global.hp[chartarget] = round(-global.maxhp[chartarget] / 2);
65
                    
scr_dead
scr_dead

function
scr_dead(arg0)
{ global.charmove[arg0] = 0; global.charcantarget[arg0] = 0; global.chardead[arg0] = 1; global.charaction[arg0] = 0; global.charspecial[arg0] = 0; }
(target);
66
                }
67
            }
68
            dmgwriter = instance_create(global.charinstance[target].x, (global.charinstance[target].y + global.charinstance[target].myheight) - 24, obj_dmgwriter);
69
            dmgwriter.damage = hpdiff;
70
            dmgwriter.type = doomtype;
71
        }
72
        if (target == 3)
73
        {
74
            for (hpi = 0; hpi < 3; hpi += 1)
75
            {
76
                chartarget = global.char[hpi];
77
                if (global.hp[chartarget] >= 0)
78
                {
79
                    if (global.charaction[hpi] == 10)
80
                        global.hp[chartarget] -= ceil(tdamage / 2);
81
                    else
82
                        global.hp[chartarget] -= tdamage;
83
                    if (global.hp[chartarget] <= 0)
84
                        global.hp[chartarget] = round(-global.maxhp[0] / 2);
85
                }
86
            }
87
        }
88
        global.inv = global.invc * 40;
89
        scr_damage_check();
90
        gameover = 1;
91
        if (global.char[0] != 0 && global.hp[global.char[0]] > 0)
92
            gameover = 0;
93
        if (global.char[1] != 0 && global.hp[global.char[1]] > 0)
94
            gameover = 0;
95
        if (global.char[2] != 0 && global.hp[global.char[2]] > 0)
96
            gameover = 0;
97
        if (gameover == 1)
98
            
scr_gameover
scr_gameover

function
scr_gameover()
{ audio_stop_all(); snd_play(snd_hurt1); if (room != room_forest_fightsusie) { global.screenshot = sprite_create_from_surface(application_surface, 0, 0, __view_get(e__VW.WView, 0), __view_get(e__VW.HView, 0), 0, 0, 0, 0); snd_free_all(); room_goto(room_gameover ); } else { global.entrance = 0; global.tempflag[9] = 1; room_goto(room_forest_savepoint3_ch1 Maze - Exit (SAVE point)); } } enum e__VW { XView, YView, WView, HView, Angle, HBorder, VBorder, HSpeed, VSpeed, Object, Visible, XPort, YPort, WPort, HPort, Camera, SurfaceID }
();
99
    }
100
}