Deltarune (Chapter 2) 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 (global.flag[39 dojo_abort?] == 1) techwon = 1; if (techwon == 1) scr_wincombat(); if (techwon == 0) { with (obj_battlecontroller) { messagepriority = -1; attackpriority = -1; } 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) { global.hittarget[i] = 0; 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.actingsingle[i] = 0; global.actingsimul[i] = 0; global.actingtarget[i] = 0; global.temptension[i] = global.tension; global.charspecial[i] = 0; global.targeted[i] = 0; global.charaction[i] = 0; global.faceaction[i] = 0; global.monsterattackname[i] = " "; } global.currentactingchar = 0; with (obj_monsterparent) { attacked = 0; talked = 0; acting = 0; actingsus = 0; actingral = 0; actingnoe = 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]; } } ...
()
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 (global.flag[39 dojo_abort?] == 1)
13
        techwon = 1;
14
    if (techwon == 1)
15
        scr_wincombat
scr_wincombat

function scr_wincombat() { if (global.flag[60 dojo_next_encounter] == 0 || global.flag[36 dojo_failure] == 1) { global.myfight = 7; global.mnfight = -1; with (obj_battlecontroller) victory = 1; for (i = 0; i < 3; i += 1) { if (global.monster[i] == 1 && i_ex(global.monsterinstance[i])) { with (global.monsterinstance[i]) scr_monsterdefeat(); } } } else { for (i = 0; i < 3; i += 1) { if (global.monster[i] == 1 && i_ex(global.monsterinstance[i])) { with (global.monsterinstance[i]) scr_monsterdefeat(); } } global.encounterno = global.flag[60 dojo_next_encounter]; scr_encountersetup(global.encounterno); global.flag[60 dojo_next_encounter] = 0; for (__j = 0; __j < 3; __j++) { if (global.monstertype[__j] != 0(None)) { _newmonster = scr_monster_add(global.monstertype[__j], global.monsterinstancetype[__j]); global.monsterinstance[_newmonster].x = camerax() + 800; global.monsterinstance[_newmonster].y = global.monstermakey[__j]; with (global.monsterinstance[_newmonster]) scr_move_to_point_over_time(global.monstermakex[myself], global.monstermakey[myself], 10); } } global.myfight = 5; myfightreturntimer = 15; global.mnfight = -1; } }
();
16
    if (techwon == 0)
17
    {
18
        with (obj_battlecontroller)
19
        {
20
            messagepriority = -1;
21
            attackpriority = -1;
22
        }
23
        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; } } }
();
24
        global.mnfight = 0;
25
        global.myfight = 0;
26
        global.bmenuno = 0;
27
        global.charturn = 0;
28
        skip = 0;
29
        for (i = 0; i < 3; i += 1)
30
        {
31
            global.hittarget[i] = 0;
32
            with (global.charinstance[i])
33
                tu = 0;
34
            hptarget = global.char[i];
35
            if (global.char[i] != 0 && global.hp[hptarget] <= 0)
36
            {
37
                healamt = ceil(global.maxhp[hptarget] / 8);
38
                dmgwr = instance_create(global.charinstance[i].x, (global.charinstance[i].y + global.charinstance[i].myheight) - 24, obj_dmgwriter);
39
                with (dmgwr)
40
                {
41
                    delay = 1;
42
                    type = 3;
43
                }
44
                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);
45
                if (global.hp[hptarget] >= 1)
46
                {
47
                    with (dmgwr)
48
                        specialmessage = 4;
49
                }
50
            }
51
        }
52
        if (global.charmove[0] == 0 || global.charauto[global.char[0]] == 1)
53
            global.charturn = 1;
54
        if (global.charturn == 1)
55
        {
56
            if (global.charmove[1] == 0 || global.charauto[global.char[1]] == 1)
57
                global.charturn = 2;
58
        }
59
        if (global.charturn == 2)
60
        {
61
            if (global.charmove[2] == 0 || global.charauto[global.char[2]] == 1)
62
                skip = 1;
63
        }
64
        for (i = 0; i < 3; i += 1)
65
        {
66
            global.acting[i] = 0;
67
            global.actingsingle[i] = 0;
68
            global.actingsimul[i] = 0;
69
            global.actingtarget[i] = 0;
70
            global.temptension[i] = global.tension;
71
            global.charspecial[i] = 0;
72
            global.targeted[i] = 0;
73
            global.charaction[i] = 0;
74
            global.faceaction[i] = 0;
75
            global.monsterattackname[i] = " ";
76
        }
77
        global.currentactingchar = 0;
78
        with (obj_monsterparent)
79
        {
80
            attacked = 0;
81
            talked = 0;
82
            acting = 0;
83
            actingsus = 0;
84
            actingral = 0;
85
            actingnoe = 0;
86
        }
87
        if (skip == 1)
88
        {
89
            if (global.char[0] == 2 && global.charauto[2] == 1)
90
            {
91
                global.acting[0] = 1;
92
                global.myfight = 3;
93
            }
94
            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) { global.monsterattackname[i] = " "; 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; } __noactors = 1; if (global.acting[0] == 1) __noactors = 0; for (__noactorsi = 0; __noactorsi < 3; __noactorsi++) { if (global.actingsingle[__noactorsi] == 1) __noactors = 0; } if (__noactors == 1) { scr_attackphase(); } else { global.charturn = 3; global.myfight = 3; global.currentactingchar = 0; if (global.acting[0] == 0) scr_nextact(); if (global.chapter == 2 && instance_exists(obj_sweet_enemy) && global.actingsingle[0] == 1 && global.actingsingle[1] == 0 && global.actingsingle[2] == 0) obj_sweet_enemy.simultotal_funny = 1; if (global.acting[0] == 1 && global.actingsimul[0] == 1) scr_act_simul(); } with (obj_battlecontroller) { messagepriority = -1; attackpriority = -1; } }
();
95
        }
96
        for (i = 0; i < 12; i += 1)
97
        {
98
            for (j = 0; j < 3; j += 1)
99
                tempitem[i][j] = global.item[i];
100
        }
101
    }
102
}