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