Deltarune (Chapter 2) script viewer

← back to main script listing

gml_GlobalScript_scr_damage_proportional

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

function scr_damage_proportional() { if (global.inv < 0) { scr_damage_cache(); if (target == 4) { scr_randomtarget_old(); target = mytarget; } if (target < 3) { if (global.hp[global.char[target]] <= 0) { scr_randomtarget_old(); target = mytarget; with (global.charinstance[target]) { image_blend = c_white; darkify = 0; } } } chartarget = 3; var _targetChar = global.char[target]; if (global.hp[_targetChar] > (global.maxhp[_targetChar] / 2)) tdamage = ceil(global.maxhp[_targetChar] / 5); else if (global.hp[_targetChar] > (global.maxhp[_targetChar] / 5)) tdamage = ceil(global.maxhp[_targetChar] / 10); else if (global.hp[_targetChar] > (global.maxhp[_targetChar] / 20)) tdamage = ceil(global.maxhp[_targetChar] / 25); else if (global.hp[_targetChar] > 1) tdamage = global.hp[_targetChar] - 1; else tdamage = 25; 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(); ...
()
2
{
3
    if (global.inv < 0)
4
    {
5
        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 }
();
6
        if (target == 4)
7
        {
8
            scr_randomtarget_old
scr_randomtarget_old

function scr_randomtarget_old() { 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; }
();
9
            target = mytarget;
10
        }
11
        if (target < 3)
12
        {
13
            if (global.hp[global.char[target]] <= 0)
14
            {
15
                scr_randomtarget_old
scr_randomtarget_old

function scr_randomtarget_old() { 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; }
();
16
                target = mytarget;
17
                with (global.charinstance[target])
18
                {
19
                    image_blend = c_white;
20
                    darkify = 0;
21
                }
22
            }
23
        }
24
        chartarget = 3;
25
        var _targetChar = global.char[target];
26
        if (global.hp[_targetChar] > (global.maxhp[_targetChar] / 2))
27
            tdamage = ceil(global.maxhp[_targetChar] / 5);
28
        else if (global.hp[_targetChar] > (global.maxhp[_targetChar] / 5))
29
            tdamage = ceil(global.maxhp[_targetChar] / 10);
30
        else if (global.hp[_targetChar] > (global.maxhp[_targetChar] / 20))
31
            tdamage = ceil(global.maxhp[_targetChar] / 25);
32
        else if (global.hp[_targetChar] > 1)
33
            tdamage = global.hp[_targetChar] - 1;
34
        else
35
            tdamage = 25;
36
        if (target < 3)
37
        {
38
            tdamage = ceil(tdamage - (global.battledf[target] * 3));
39
            chartarget = global.char[target];
40
            if (global.charaction[target] == 10)
41
                tdamage = ceil((2 * tdamage) / 3);
42
            if (tdamage < 1)
43
                tdamage = 1;
44
        }
45
        if (!instance_exists(obj_shake))
46
            instance_create(0, 0, obj_shake);
47
        with (global.charinstance[target])
48
        {
49
            hurt = 1;
50
            hurttimer = 0;
51
        }
52
        hpdiff = tdamage;
53
        with (obj_dmgwriter)
54
        {
55
            if (delaytimer >= 1)
56
                killactive = 1;
57
        }
58
        doomtype = -1;
59
        with (obj_heart)
60
            dmgnoise = 1;
61
        if (target < 3)
62
        {
63
            if (global.hp[chartarget] <= 0)
64
            {
65
                doomtype = 4;
66
                global.hp[chartarget] -= round(tdamage / 4);
67
                hpdiff = round(tdamage / 4);
68
            }
69
            else
70
            {
71
                global.hp[chartarget] -= tdamage;
72
                if (global.hp[chartarget] <= 0)
73
                {
74
                    hpdiff = abs(global.hp[chartarget] - (global.maxhp[chartarget] / 2));
75
                    doomtype = 4;
76
                    global.hp[chartarget] = round(-global.maxhp[chartarget] / 2);
77
                    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);
78
                }
79
            }
80
            dmgwriter = instance_create(global.charinstance[target].x, (global.charinstance[target].y + global.charinstance[target].myheight) - 24, obj_dmgwriter);
81
            dmgwriter.damage = hpdiff;
82
            dmgwriter.type = doomtype;
83
        }
84
        if (target == 3)
85
        {
86
            for (hpi = 0; hpi < 3; hpi += 1)
87
            {
88
                chartarget = global.char[hpi];
89
                if (global.hp[chartarget] >= 0)
90
                {
91
                    if (global.charaction[hpi] == 10)
92
                        global.hp[chartarget] -= ceil(tdamage / 2);
93
                    else
94
                        global.hp[chartarget] -= tdamage;
95
                    if (global.hp[chartarget] <= 0)
96
                        global.hp[chartarget] = round(-global.maxhp[0] / 2);
97
                }
98
            }
99
        }
100
        global.inv = global.invc * 40;
101
        scr_damage_check();
102
        gameover = 1;
103
        if (global.char[0] != 0 && global.hp[global.char[0]] > 0)
104
            gameover = 0;
105
        if (global.char[1] != 0 && global.hp[global.char[1]] > 0)
106
            gameover = 0;
107
        if (global.char[2] != 0 && global.hp[global.char[2]] > 0)
108
            gameover = 0;
109
        if (gameover == 1)
110
            scr_gameover
scr_gameover

function scr_gameover() { if (global.chapter == 2) { if (room == room_dw_mansion_b_west_2f) global.tempflag[33]++; if (room == room_dw_mansion_east_4f_d && i_ex(obj_queen_enemy)) { global.hp[1] = global.maxhp[1]; global.hp[2] = global.maxhp[2]; global.hp[3] = global.maxhp[3]; scr_tempsave(); } if (i_ex(obj_spamton_neo_enemy)) global.tempflag[37]++; } if (global.flag[35 gameover_mode] == 0) { audio_stop_all(); snd_play(snd_hurt1); 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 }
();
111
    }
112
}