Deltarune (Chapter 5) script viewer

← back to main script listing

gml_GlobalScript_scr_damage_enemy

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

function
scr_damage_enemy(arg0, arg1)
{ dm = instance_create(global.monsterx[arg0], (global.monstery[arg0] + 20) - (global.hittarget[arg0] * 20), obj_dmgwriter); if (caster < 4) { dm.type = global.char[caster] - 1; if (global.char[caster] == 4) dm.type = 6; } if (caster == 5) dm.type = 5; dm.damage = arg1; global.monsterhp[arg0] -= arg1; with (global.monsterinstance[arg0]) { if (variable_instance_exists(id, "callback_on_damage")) callback_on_damage(id); } if (arg1 > 0) { with (global.monsterinstance[arg0]) { shakex = 9; state = 3; hurttimer = 30; } if (i_ex(global.monsterinstance[arg0])) global.monsterinstance[arg0].hurtamt = arg1; } global.hittarget[arg0] += 1; if (arg1 == 0) { with (global.monsterinstance[arg0]) { hurtamt = 0; if (hurttimer <= 15 && candodge == 1) { dodgetimer = 0; state = 4; } } } var a = 0; if (global.monsterhp[arg0] <= 0 && a == 0) { with (global.monsterinstance[arg0])
scr_monsterdefeat();
} }
(arg0, arg1)
2
{
3
    dm = instance_create(global.monsterx[arg0], (global.monstery[arg0] + 20) - (global.hittarget[arg0] * 20), obj_dmgwriter);
4
    if (caster < 4)
5
    {
6
        dm.type = global.char[caster] - 1;
7
        if (global.char[caster] == 4)
8
            dm.type = 6;
9
    }
10
    if (caster == 5)
11
        dm.type = 5;
12
    dm.damage = arg1;
13
    global.monsterhp[arg0] -= arg1;
14
    with (global.monsterinstance[arg0])
15
    {
16
        if (variable_instance_exists(id, "callback_on_damage"))
17
            callback_on_damage(id);
18
    }
19
    if (arg1 > 0)
20
    {
21
        with (global.monsterinstance[arg0])
22
        {
23
            shakex = 9;
24
            state = 3;
25
            hurttimer = 30;
26
        }
27
        if (i_ex(global.monsterinstance[arg0]))
28
            global.monsterinstance[arg0].hurtamt = arg1;
29
    }
30
    global.hittarget[arg0] += 1;
31
    if (arg1 == 0)
32
    {
33
        with (global.monsterinstance[arg0])
34
        {
35
            hurtamt = 0;
36
            if (hurttimer <= 15 && candodge == 1)
37
            {
38
                dodgetimer = 0;
39
                state = 4;
40
            }
41
        }
42
    }
43
    var a = 0;
44
    if (global.monsterhp[arg0] <= 0 && a == 0)
45
    {
46
        with (global.monsterinstance[arg0])
47
            
scr_monsterdefeat
scr_monsterdefeat

function
scr_monsterdefeat()
{ if (global.monster[myself] == 1) { debug_message("==
scr_monsterdefeat() called ==");
debug_message("===== Encounter Results ====="); global.monstergold[3] += global.monstergold[myself]; global.monsterexp[3] += global.monsterexp[myself]; global.monster[myself] = 0; if (global.flag[51 + myself] == 0) { global.flag[51 + myself] = 2; if (global.monsterhp[myself] <= 0) global.flag[51 + myself] = 1; } if (global.flag[51 + myself] == 1) { global.flag[40 violences] += 1; if (fatal == 1) global.flag[44 kills]++; } if (global.flag[51 + myself] == 2) global.flag[41 spares] += 1; if (global.flag[51 + myself] == 3) global.flag[42 pacifies] += 1; if (global.flag[51 + myself] == 5) global.flag[43 autosusie_violences] += 1; if (global.flag[51 + myself] == 6) { global.flag[45 freezes] += 1; global.monstergold[3] += 24; } if (
scr_monsterpop() == 0)
{ var _amt_add = 0; var _frozened = 0; var _violenced = 0; var _spared = 0; var _pacified = 0; for (var d_i = 0; d_i < 3; d_i++) { if (global.flag[51 + d_i] != 0) _amt_add += 1; if (global.flag[51 + d_i] == 1) _violenced += 1; if (global.flag[51 + d_i] == 2) _spared += 1; if (global.flag[51 + d_i] == 3) _pacified += 1; if (global.flag[51 + d_i] == 6) _frozened += 1; } if (_frozened > 0) global.flag[50 last_encounter_end] = 6; if (_pacified > 0) global.flag[50 last_encounter_end] = 3; if (_spared > 0) global.flag[50 last_encounter_end] = 2; if (_violenced > 0) global.flag[50 last_encounter_end] = 1; if (global.flag[50 last_encounter_end] == 6) global.flag[926 iceshocked_encounters]++; if (global.flag[54 encounter_pointer] != 0) { global.flag[global.flag[54 encounter_pointer]] = global.flag[50 last_encounter_end]; debug_message("encounter flag: global.flag[" + string(global.flag[54 encounter_pointer]) + "]=" + string(global.flag[50 last_encounter_end])); global.flag[54 encounter_pointer] = 0; } } event_user(11); debug_message("======="); } }
();
48
    }
49
}