Deltarune (Chapter 4) script viewer

← back to main script listing

gml_GlobalScript_scr_become_light

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

function
scr_become_light()
{ if (
scr_litemcheck(5) == 0)
scr_litemget(5);
if (
scr_keyitemcheck(2))
{ if (
scr_litemcheck(8) == 0)
scr_litemget(8);
} else {
scr_litemremove(8);
} if (
scr_keyitemcheck(13))
{ if (
scr_litemcheck(11) == 0)
scr_litemget(11);
} else {
scr_litemremove(11);
} global.lhp = ceil((global.hp[1] / global.maxhp[1]) * global.lmaxhp); if (global.lhp < 1) global.lhp = 1; if (global.lhp > global.lmaxhp) global.lhp = global.lmaxhp; scr_equip_lw_weapon_by_dw_id(global.charweapon[1]); global.lwstrength = get_lw_weapon_strength(global.lweapon); if (
scr_weaponcheck_inventory(26) > 0 || 
scr_weaponcheck_equipped_any(26) > 0)
{ if (!
scr_litemcheck(17) && global.lweapon != 17)
scr_litemget(17);
} var armorconverted = 0; if (
scr_armorcheck_equipped(1, 14) > 0)
{ armorconverted = 1; global.larmor = 14; } if (armorconverted == 1) global.ladef = 1; else global.ladef = 0; global.darkzone = 0; }
()
2
{
3
    if (
scr_litemcheck
scr_litemcheck

function
scr_litemcheck(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 8; i += 1) { if (global.litem[i] == arg0) haveit = 1; if (global.litem[i] == arg0) itemcount += 1; } return haveit; }
(5) == 0)
4
        
scr_litemget
scr_litemget

function
scr_litemget(arg0)
{ i = 0; loop = 1; noroom = 0; global.litem[8] = 999; while (loop == 1) { if (global.litem[i] == 0) { global.litem[i] = arg0; break; } if (i == 8) { noroom = 1; break; } i += 1; }
scr_litemname();
}
(5);
5
    if (
scr_keyitemcheck
scr_keyitemcheck

function
scr_keyitemcheck(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 12; i += 1) { if (global.keyitem[i] == arg0) haveit = 1; if (global.keyitem[i] == arg0) itemcount += 1; } return haveit; }
(2))
6
    {
7
        if (
scr_litemcheck
scr_litemcheck

function
scr_litemcheck(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 8; i += 1) { if (global.litem[i] == arg0) haveit = 1; if (global.litem[i] == arg0) itemcount += 1; } return haveit; }
(8) == 0)
8
            
scr_litemget
scr_litemget

function
scr_litemget(arg0)
{ i = 0; loop = 1; noroom = 0; global.litem[8] = 999; while (loop == 1) { if (global.litem[i] == 0) { global.litem[i] = arg0; break; } if (i == 8) { noroom = 1; break; } i += 1; }
scr_litemname();
}
(8);
9
    }
10
    else
11
    {
12
        
scr_litemremove
scr_litemremove

function
scr_litemremove(arg0)
{ for (i = 0; i < 8; i += 1) { if (global.litem[i] == arg0) script_execute(scr_litemshift, i, 0); } }
(8);
13
    }
14
    if (
scr_keyitemcheck
scr_keyitemcheck

function
scr_keyitemcheck(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 12; i += 1) { if (global.keyitem[i] == arg0) haveit = 1; if (global.keyitem[i] == arg0) itemcount += 1; } return haveit; }
(13))
15
    {
16
        if (
scr_litemcheck
scr_litemcheck

function
scr_litemcheck(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 8; i += 1) { if (global.litem[i] == arg0) haveit = 1; if (global.litem[i] == arg0) itemcount += 1; } return haveit; }
(11) == 0)
17
            
scr_litemget
scr_litemget

function
scr_litemget(arg0)
{ i = 0; loop = 1; noroom = 0; global.litem[8] = 999; while (loop == 1) { if (global.litem[i] == 0) { global.litem[i] = arg0; break; } if (i == 8) { noroom = 1; break; } i += 1; }
scr_litemname();
}
(11);
18
    }
19
    else
20
    {
21
        
scr_litemremove
scr_litemremove

function
scr_litemremove(arg0)
{ for (i = 0; i < 8; i += 1) { if (global.litem[i] == arg0) script_execute(scr_litemshift, i, 0); } }
(11);
22
    }
23
    global.lhp = ceil((global.hp[1] / global.maxhp[1]) * global.lmaxhp);
24
    if (global.lhp < 1)
25
        global.lhp = 1;
26
    if (global.lhp > global.lmaxhp)
27
        global.lhp = global.lmaxhp;
28
    scr_equip_lw_weapon_by_dw_id(global.charweapon[1]);
29
    global.lwstrength = get_lw_weapon_strength(global.lweapon);
30
    if (
scr_weaponcheck_inventory
scr_weaponcheck_inventory

function
scr_weaponcheck_inventory(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 48; i += 1) { if (global.weapon[i] == arg0) haveit = 1; if (global.weapon[i] == arg0) itemcount += 1; } return haveit; }
(26) > 0 ||
scr_weaponcheck_equipped_any
scr_weaponcheck_equipped_any

function
scr_weaponcheck_equipped_any(arg0)
{ var __totalwearing = 0; for (var __weari = 0; __weari < array_length_1d(global.charweapon); __weari++) __totalwearing +=
scr_weaponcheck_equipped(__weari, arg0);
return __totalwearing; }
(26) > 0)
31
    {
32
        if (!
scr_litemcheck
scr_litemcheck

function
scr_litemcheck(arg0)
{ haveit = 0; itemcount = 0; for (i = 0; i < 8; i += 1) { if (global.litem[i] == arg0) haveit = 1; if (global.litem[i] == arg0) itemcount += 1; } return haveit; }
(17) && global.lweapon != 17)
33
            
scr_litemget
scr_litemget

function
scr_litemget(arg0)
{ i = 0; loop = 1; noroom = 0; global.litem[8] = 999; while (loop == 1) { if (global.litem[i] == 0) { global.litem[i] = arg0; break; } if (i == 8) { noroom = 1; break; } i += 1; }
scr_litemname();
}
(17);
34
    }
35
    var armorconverted = 0;
36
    if (
scr_armorcheck_equipped
scr_armorcheck_equipped

function
scr_armorcheck_equipped(arg0, arg1)
{ var __wearing = 0; if (global.chararmor1[arg0] == arg1) __wearing++; if (global.chararmor2[arg0] == arg1) __wearing++; return __wearing; }
(1, 14) > 0)
37
    {
38
        armorconverted = 1;
39
        global.larmor = 14;
40
    }
41
    if (armorconverted == 1)
42
        global.ladef = 1;
43
    else
44
        global.ladef = 0;
45
    global.darkzone = 0;
46
}