Deltarune (Chapter 5) script viewer

← back to main script listing

gml_GlobalScript_scr_damage_all_platmode

(view raw script w/o annotations or w/e)
1
function scr_damage_calculation_plat(arg0, arg1)
2
{
3
    if (arg0 <= 0)
4
        return arg0;
5
    var _tdamage = arg0;
6
    var _tdef = global.battledf[arg1];
7
    var _finaldamage = 1;
8
    _tdamage -= _tdef;
9
    return max(_tdamage, _finaldamage);
10
}
11
12
function 
scr_damage_all_platmode
scr_damage_all_platmode

function scr_damage_calculation_plat(arg0, arg1) { if (arg0 <= 0) return arg0; var _tdamage = arg0; var _tdef = global.battledf[arg1]; var _finaldamage = 1; _tdamage -= _tdef; return max(_tdamage, _finaldamage); } function
scr_damage_all_platmode()
{ if (global.inv < 0) { gameover = 1; if (global.char[0] != 0 && global.hp[global.char[0]] > 1) gameover = 0; if (global.char[1] != 0 && global.hp[global.char[1]] > 1) gameover = 0; if (global.char[2] != 0 && global.hp[global.char[2]] > 1) gameover = 0; if (global.chapter == 5 && gameover && global.tempflag[57] == 1) { if (global.char[0] != 0) global.hp[global.char[0]] = 0; if (global.char[1] != 0) global.hp[global.char[1]] = 0; if (global.char[2] != 0) global.hp[global.char[2]] = 0; exit; } if (gameover == 1)
scr_gameover();
remdamage = damage; remtarget = target; if (!instance_exists(obj_shake)) instance_create(0, 0, obj_shake); with (obj_dmgwriter) killactive = 1; snd_stop(snd_hurt1); snd_play(snd_hurt1); var maxhpdiff = 0; for (ti = 0; ti < 3; ti += 1) { global.inv = -1; damage = remdamage; target = ti; tdamage = scr_damage_calculation_plat(damage, target); with (global.charinstance[target]) { hurt = 1; hurttimer = 0; } hpdiff = tdamage; if (hpdiff >= global.hp[global.char[target]]) hpdiff = global.hp[global.char[target]] - 1; maxhpdiff = max(hpdiff, maxhpdiff); d_cancel = 0; if (hpdiff <= 1) { if (global.hp[global.char[target]] <= 0) { hpdiff = 0; d_cancel = 1; } else { hpdiff = 1; } } if (d_cancel == 0) { doomtype = -1; global.hp[global.char[target]] -= hpdiff; if ((instance_exists(global.charinstance[target]) && global.charinstance[target].visible == true) || i_ex(obj_climb_kris) || i_ex(obj_plat_player)) { var trg = -4; var nowriter = false; if (i_ex(obj_plat_player)) { trg = 910; if (ti > 0) { with (obj_plat_follower) { if (name == "susie" && other.ti == 1) trg = self; if (name == "ralsei" && other.ti == 2) trg = self; } if (trg == 910) { if (hpdiff == maxhpdiff) { with (dmgwriter) damage = maxhpdiff; } nowriter = true; } } ...
()
13
{
14
    if (global.inv < 0)
15
    {
16
        gameover = 1;
17
        if (global.char[0] != 0 && global.hp[global.char[0]] > 1)
18
            gameover = 0;
19
        if (global.char[1] != 0 && global.hp[global.char[1]] > 1)
20
            gameover = 0;
21
        if (global.char[2] != 0 && global.hp[global.char[2]] > 1)
22
            gameover = 0;
23
        if (global.chapter == 5 && gameover && global.tempflag[57] == 1)
24
        {
25
            if (global.char[0] != 0)
26
                global.hp[global.char[0]] = 0;
27
            if (global.char[1] != 0)
28
                global.hp[global.char[1]] = 0;
29
            if (global.char[2] != 0)
30
                global.hp[global.char[2]] = 0;
31
            exit;
32
        }
33
        if (gameover == 1)
34
            
scr_gameover
scr_gameover

function
scr_gameover(arg0 = true)
{ if (global.chapter == 5) { global.flag[57] = 0; if (i_ex(obj_flowery_enemy) && global.flag[1865] == 1) global.flag[1865] = 2; with (obj_orangeheart_floweryjarona) stopthat = true; } if (global.flag[35 gameover_mode] == 0) { audio_stop_all(); if (arg0) snd_play(snd_hurt1); global.gameover_room = room; 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 ); } if (global.flag[35 gameover_mode] == 1) { global.turntimer = -1; global.flag[36 dojo_failure] = 1; global.flag[39 dojo_abort?] = 1; } if (global.flag[35 gameover_mode] == 2) { audio_stop_all(); snd_play(snd_hurt1); snd_free_all(); global.entrance = 0; global.tempflag[9] = 1; global.fighting = 0; global.interact = 0; global.hp[0] = 1; global.hp[1] = 1; global.hp[2] = 1; global.hp[3] = 1; __room = room; if (global.chapter == 2) { with (instance_create(0, 0, obj_persistentfadein)) image_alpha = 1.2; } room_goto(__room); } } enum e__VW { XView, YView, WView, HView, Angle, HBorder, VBorder, HSpeed, VSpeed, Object, Visible, XPort, YPort, WPort, HPort, Camera, SurfaceID }
();
35
        remdamage = damage;
36
        remtarget = target;
37
        if (!instance_exists(obj_shake))
38
            instance_create(0, 0, obj_shake);
39
        with (obj_dmgwriter)
40
            killactive = 1;
41
        snd_stop(snd_hurt1);
42
        snd_play(snd_hurt1);
43
        var maxhpdiff = 0;
44
        for (ti = 0; ti < 3; ti += 1)
45
        {
46
            global.inv = -1;
47
            damage = remdamage;
48
            target = ti;
49
            tdamage = scr_damage_calculation_plat(damage, target);
50
            with (global.charinstance[target])
51
            {
52
                hurt = 1;
53
                hurttimer = 0;
54
            }
55
            hpdiff = tdamage;
56
            if (hpdiff >= global.hp[global.char[target]])
57
                hpdiff = global.hp[global.char[target]] - 1;
58
            maxhpdiff = max(hpdiff, maxhpdiff);
59
            d_cancel = 0;
60
            if (hpdiff <= 1)
61
            {
62
                if (global.hp[global.char[target]] <= 0)
63
                {
64
                    hpdiff = 0;
65
                    d_cancel = 1;
66
                }
67
                else
68
                {
69
                    hpdiff = 1;
70
                }
71
            }
72
            if (d_cancel == 0)
73
            {
74
                doomtype = -1;
75
                global.hp[global.char[target]] -= hpdiff;
76
                if ((instance_exists(global.charinstance[target]) && global.charinstance[target].visible == true) || i_ex(obj_climb_kris) || i_ex(obj_plat_player))
77
                {
78
                    var trg = -4;
79
                    var nowriter = false;
80
                    if (i_ex(obj_plat_player))
81
                    {
82
                        trg = 910;
83
                        if (ti > 0)
84
                        {
85
                            with (obj_plat_follower)
86
                            {
87
                                if (name == "susie" && other.ti == 1)
88
                                    trg = self;
89
                                if (name == "ralsei" && other.ti == 2)
90
                                    trg = self;
91
                            }
92
                            if (trg == 910)
93
                            {
94
                                if (hpdiff == maxhpdiff)
95
                                {
96
                                    with (dmgwriter)
97
                                        damage = maxhpdiff;
98
                                }
99
                                nowriter = true;
100
                            }
101
                        }
102
                    }
103
                    else if (i_ex(obj_climb_kris))
104
                    {
105
                        trg = 1164;
106
                        if (ti > 0)
107
                        {
108
                            with (obj_climb_susie)
109
                            {
110
                                if (name == "susie" && other.ti == 1)
111
                                    trg = self;
112
                                if (name == "ralsei" && other.ti == 2)
113
                                    trg = self;
114
                            }
115
                            if (trg == 1164)
116
                            {
117
                                if (hpdiff == maxhpdiff)
118
                                {
119
                                    with (dmgwriter)
120
                                        damage = maxhpdiff;
121
                                }
122
                                nowriter = true;
123
                            }
124
                        }
125
                    }
126
                    if (!nowriter)
127
                    {
128
                        dmgwriter = instance_create(x, y, obj_dmgwriter);
129
                        dmgwriter.damage = hpdiff;
130
                        dmgwriter.type = doomtype;
131
                        if (i_ex(obj_climb_kris) || i_ex(obj_plat_player))
132
                        {
133
                            dmgwriter.x = trg.x;
134
                            dmgwriter.y = trg.y;
135
                            dmgwriter.ystart = trg.y;
136
                            dmgwriter.depth = trg.depth - 100;
137
                            if (i_ex(obj_plat_player))
138
                            {
139
                                dmgwriter.depth = 1650;
140
                                if (obj_plat_player.dashing)
141
                                    dmgwriter.slidespeedx = obj_plat_player.hspeed;
142
                            }
143
                            if (variable_instance_exists(trg, "onrotatingtower") && trg.onrotatingtower == true)
144
                                dmgwriter.x = camerax() + (camerawidth() / 2);
145
                        }
146
                        else if (instance_exists(global.charinstance[target]))
147
                        {
148
                            dmgwriter.x = global.charinstance[target].x;
149
                            dmgwriter.y = (global.charinstance[target].y + global.charinstance[target].myheight) - 24;
150
                        }
151
                    }
152
                }
153
                if (global.hp[global.char[target]] < 1)
154
                    global.hp[global.char[target]] = 1;
155
            }
156
        }
157
        target = remtarget;
158
        global.inv = global.invc * 40;
159
    }
160
}