Deltarune (Chapter 1) script viewer

← back to main script listing

gml_GlobalScript_scr_mnendturn

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

function scr_mnendturn() { if (global.char[0] == 2) sus = 0; if (global.char[1] == 2) sus = 1; if (global.char[2] == 2) sus = 2; techwon = 0; if (scr_monsterpop() == 0) techwon = 1; if (techwon == 0) { scr_battlecursor_memory_reset(); global.mnfight = 0; global.myfight = 0; global.bmenuno = 0; global.charturn = 0; skip = 0; for (i = 0; i < 3; i += 1) { with (global.charinstance[i]) tu = 0; hptarget = global.char[i]; if (global.char[i] != 0 && global.hp[hptarget] <= 0) { healamt = ceil(global.maxhp[hptarget] / 8); dmgwr = instance_create(global.charinstance[i].x, (global.charinstance[i].y + global.charinstance[i].myheight) - 24, obj_dmgwriter); with (dmgwr) { delay = 1; type = 3; } dmgwr.damage = scr_heal(i, healamt); if (global.hp[hptarget] >= 1) { with (dmgwr) specialmessage = 4; } } } if (global.charmove[0] == 0 || global.charauto[global.char[0]] == 1) global.charturn = 1; if (global.charturn == 1) { if (global.charmove[1] == 0 || global.charauto[global.char[1]] == 1) global.charturn = 2; } if (global.charturn == 2) { if (global.charmove[2] == 0 || global.charauto[global.char[2]] == 1) skip = 1; } for (i = 0; i < 3; i += 1) { global.acting[i] = 0; global.temptension[i] = global.tension; global.charspecial[i] = 0; global.targeted[i] = 0; global.charaction[i] = 0; global.faceaction[i] = 0; } with (obj_monsterparent) { attacked = 0; talked = 0; acting = 0; } if (skip == 1) { if (global.char[0] == 2 && global.charauto[2] == 1) { global.acting[0] = 1; global.myfight = 3; } scr_endturn(); } for (i = 0; i < 12; i += 1) { for (j = 0; j < 3; j += 1) tempitem[i][j] = global.item[i]; } } else { scr_wincombat(); } }
()
2
{
3
    if (global.char[0] == 2)
4
        sus = 0;
5
    if (global.char[1] == 2)
6
        sus = 1;
7
    if (global.char[2] == 2)
8
        sus = 2;
9
    techwon = 0;
10
    if (scr_monsterpop
scr_monsterpop

function scr_monsterpop() { return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
11
        techwon = 1;
12
    if (techwon == 0)
13
    {
14
        scr_battlecursor_memory_reset
scr_battlecursor_memory_reset

function scr_battlecursor_memory_reset() { if (global.flag[14 remember_battle_menu] == 0) { for (i = 0; i < 20; i += 1) { for (j = 0; j < 20; j += 1) global.bmenucoord[i][j] = 0; } } }
();
15
        global.mnfight = 0;
16
        global.myfight = 0;
17
        global.bmenuno = 0;
18
        global.charturn = 0;
19
        skip = 0;
20
        for (i = 0; i < 3; i += 1)
21
        {
22
            with (global.charinstance[i])
23
                tu = 0;
24
            hptarget = global.char[i];
25
            if (global.char[i] != 0 && global.hp[hptarget] <= 0)
26
            {
27
                healamt = ceil(global.maxhp[hptarget] / 8);
28
                dmgwr = instance_create(global.charinstance[i].x, (global.charinstance[i].y + global.charinstance[i].myheight) - 24, obj_dmgwriter);
29
                with (dmgwr)
30
                {
31
                    delay = 1;
32
                    type = 3;
33
                }
34
                dmgwr.damage = scr_heal
scr_heal

function scr_heal(arg0, arg1) { abovemaxhp = 0; belowzero = 0; hltarget = global.char[arg0]; _curhp = global.hp[hltarget]; if (global.hp[hltarget] <= 0) belowzero = 1; if (global.hp[hltarget] > global.maxhp[hltarget]) abovemaxhp = 1; if (abovemaxhp == 0) { global.hp[hltarget] += arg1; if (global.hp[hltarget] > global.maxhp[hltarget]) global.hp[hltarget] = global.maxhp[hltarget]; } if (belowzero == 1 && global.hp[hltarget] >= 0) { if (global.hp[hltarget] < ceil(global.maxhp[hltarget] / 6)) global.hp[hltarget] = ceil(global.maxhp[hltarget] / 6); scr_revive(arg0); } snd_stop(snd_power); snd_play(snd_power); return global.hp[hltarget] - _curhp; }
(i, healamt);
35
                if (global.hp[hptarget] >= 1)
36
                {
37
                    with (dmgwr)
38
                        specialmessage = 4;
39
                }
40
            }
41
        }
42
        if (global.charmove[0] == 0 || global.charauto[global.char[0]] == 1)
43
            global.charturn = 1;
44
        if (global.charturn == 1)
45
        {
46
            if (global.charmove[1] == 0 || global.charauto[global.char[1]] == 1)
47
                global.charturn = 2;
48
        }
49
        if (global.charturn == 2)
50
        {
51
            if (global.charmove[2] == 0 || global.charauto[global.char[2]] == 1)
52
                skip = 1;
53
        }
54
        for (i = 0; i < 3; i += 1)
55
        {
56
            global.acting[i] = 0;
57
            global.temptension[i] = global.tension;
58
            global.charspecial[i] = 0;
59
            global.targeted[i] = 0;
60
            global.charaction[i] = 0;
61
            global.faceaction[i] = 0;
62
        }
63
        with (obj_monsterparent)
64
        {
65
            attacked = 0;
66
            talked = 0;
67
            acting = 0;
68
        }
69
        if (skip == 1)
70
        {
71
            if (global.char[0] == 2 && global.charauto[2] == 1)
72
            {
73
                global.acting[0] = 1;
74
                global.myfight = 3;
75
            }
76
            scr_endturn
scr_endturn

function scr_endturn() { for (i = 0; i < 12; i += 1) global.item[i] = tempitem[i][global.charturn]; for (i = 0; i < 12; i += 1) { for (j = 0; j < 3; j += 1) tempitem[i][j] = global.item[i]; } moveswapped = 0; with (obj_writer) instance_destroy(); with (obj_face) instance_destroy(); with (obj_smallface) instance_destroy(); global.attacking = 0; for (i = 0; i < 3; i += 1) { if (global.charauto[global.char[i]] == 1 && global.hp[global.char[i]] > 0) { if (global.monster[2] == 1) global.chartarget[i] = 2; if (global.monster[1] == 1) global.chartarget[i] = 1; if (global.monster[0] == 1) global.chartarget[i] = 0; } if (global.charaction[i] == 1) global.attacking = 1; } if (global.acting[0] == 0) { scr_attackphase(); } else { global.charturn = 3; global.myfight = 3; } }
();
77
        }
78
        for (i = 0; i < 12; i += 1)
79
        {
80
            for (j = 0; j < 3; j += 1)
81
                tempitem[i][j] = global.item[i];
82
        }
83
    }
84
    else
85
    {
86
        scr_wincombat
scr_wincombat

function scr_wincombat() { global.myfight = 7; global.mnfight = -1; with (obj_battlecontroller) victory = 1; for (i = 0; i < 3; i += 1) { if (global.monster[i] == 1 && instance_exists(global.monsterinstance[i])) { with (global.monsterinstance[i]) scr_monsterdefeat(); } } }
();
87
    }
88
}