Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_scr_damage_determination_enemy_2

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

function scr_damage_determination_enemy_2(arg0) { switch (arg0) { case "Gun Single": global.attacking_damage_stat_betrayal = global.current_hp_enemy_2; global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 2.5); r = random_range(0, 2); switch (shot_type) { case "strong": b = 2.5; break; case "medium": b = 2; break; default: b = 1.5; } global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * b); break; case "Gun Multi": global.attacking_damage_stat_betrayal = global.current_hp_enemy_2; global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 2.5); r = random_range(0, 2); b = 1.5; var b_diff = 1 / circle_count; var st_temp; for (st_temp = shot_total; st_temp > 3; st_temp -= 3) b += b_diff; switch (st_temp) { case 3: b += b_diff; break; case 2: b += (0.8 * b_diff); break; default: b += (0.6 * b_diff); } global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * clamp(b, 1.5, 3)); break; case "Revolver Single": global.attacking_damage_stat_betrayal = global.current_hp_enemy_2; global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 3.5); r = random_range(0, 2); b = 0; var b_inc = 0.5833333333333334; switch (shot_type) { case "strong": b += b_inc; break; case "medium": b += (b_inc * 0.5); break; default: b = 0; } var st_temp; for (st_temp = shot_total_pre; st_temp > 3; st_temp -= 3) b += b_inc; switch (st_temp) { case 3: b += b_inc; break; case 2: b += (b_inc * 0.5); break; default: b += 0; } global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * b); break; case "Revolver Multi": global.attacking_damage_stat_betrayal = global.current_hp_enemy_2; global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat) + 2) * 3.5); r = random_range(0, 2); b = 0; var b_inc = 0.5833333333333334; var st_temp; for (st_temp = shot_total; st_temp > 3; st_temp -= 3) b += b_inc; switch (st_temp) { case 3: b += b_inc; break; case 2: b += (b_inc / 2); break; default: b += 0; } for (st_temp = shot_total_pre; st_temp > 3; st_temp -= 3) b += b_inc; switch (st_temp) { case 3: ...
(arg0)
2
{
3
    switch (arg0)
4
    {
5
        case "Gun Single":
6
            global.attacking_damage_stat_betrayal = global.current_hp_enemy_2;
7
            global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 2.5);
8
            r = random_range(0, 2);
9
            switch (shot_type)
10
            {
11
                case "strong":
12
                    b = 2.5;
13
                    break;
14
                case "medium":
15
                    b = 2;
16
                    break;
17
                default:
18
                    b = 1.5;
19
            }
20
            global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * b);
21
            break;
22
        case "Gun Multi":
23
            global.attacking_damage_stat_betrayal = global.current_hp_enemy_2;
24
            global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 2.5);
25
            r = random_range(0, 2);
26
            b = 1.5;
27
            var b_diff = 1 / circle_count;
28
            var st_temp;
29
            for (st_temp = shot_total; st_temp > 3; st_temp -= 3)
30
                b += b_diff;
31
            switch (st_temp)
32
            {
33
                case 3:
34
                    b += b_diff;
35
                    break;
36
                case 2:
37
                    b += (0.8 * b_diff);
38
                    break;
39
                default:
40
                    b += (0.6 * b_diff);
41
            }
42
            global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * clamp(b, 1.5, 3));
43
            break;
44
        case "Revolver Single":
45
            global.attacking_damage_stat_betrayal = global.current_hp_enemy_2;
46
            global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 3.5);
47
            r = random_range(0, 2);
48
            b = 0;
49
            var b_inc = 0.5833333333333334;
50
            switch (shot_type)
51
            {
52
                case "strong":
53
                    b += b_inc;
54
                    break;
55
                case "medium":
56
                    b += (b_inc * 0.5);
57
                    break;
58
                default:
59
                    b = 0;
60
            }
61
            var st_temp;
62
            for (st_temp = shot_total_pre; st_temp > 3; st_temp -= 3)
63
                b += b_inc;
64
            switch (st_temp)
65
            {
66
                case 3:
67
                    b += b_inc;
68
                    break;
69
                case 2:
70
                    b += (b_inc * 0.5);
71
                    break;
72
                default:
73
                    b += 0;
74
            }
75
            global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * b);
76
            break;
77
        case "Revolver Multi":
78
            global.attacking_damage_stat_betrayal = global.current_hp_enemy_2;
79
            global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat) + 2) * 3.5);
80
            r = random_range(0, 2);
81
            b = 0;
82
            var b_inc = 0.5833333333333334;
83
            var st_temp;
84
            for (st_temp = shot_total; st_temp > 3; st_temp -= 3)
85
                b += b_inc;
86
            switch (st_temp)
87
            {
88
                case 3:
89
                    b += b_inc;
90
                    break;
91
                case 2:
92
                    b += (b_inc / 2);
93
                    break;
94
                default:
95
                    b += 0;
96
            }
97
            for (st_temp = shot_total_pre; st_temp > 3; st_temp -= 3)
98
                b += b_inc;
99
            switch (st_temp)
100
            {
101
                case 3:
102
                    b += b_inc;
103
                    break;
104
                case 2:
105
                    b += (b_inc / 2);
106
                    break;
107
                default:
108
                    b += 0;
109
            }
110
            global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat) + r) * b);
111
            break;
112
        default:
113
            global.attacking_damage_stat_betrayal = global.current_hp_enemy_2;
114
            global.attacking_damage_stat_critical_2 = round((((global.player_weapon_attack + global.player_weapon_modifier_attack + global.player_attack) - global.enemy_defense_stat_2) + 2) * 2.2);
115
            r = random_range(0, 2);
116
            if (x == 319)
117
                b = 2.2;
118
            else
119
                b = abs(x - 319) / (obj_target_battle.sprite_width / 2);
120
            global.attacking_damage_stat = round((((global.player_weapon_attack + global.player_attack) - global.enemy_defense_stat_2) + r) * b);
121
    }
122
    if (global.attacking_damage_cap_2 >= 0)
123
    {
124
        if (global.attacking_damage_stat > global.attacking_damage_cap_2)
125
            global.attacking_damage_stat = global.attacking_damage_cap_2;
126
        if (global.attacking_damage_stat_critical_2 > global.attacking_damage_cap_2)
127
            global.attacking_damage_stat_critical_2 = global.attacking_damage_cap_2;
128
    }
129
    if (global.attacking_damage_stat < 5)
130
        global.attacking_damage_stat = 5;
131
    if (global.attacking_damage_stat_critical_2 < 5)
132
        global.attacking_damage_stat_critical_2 = 5;
133
    if (button_pressed == true)
134
    {
135
        if (global.enemy_sparing_2 == true && global.enemy_vulnerable_2 == true)
136
        {
137
            global.last_hp_enemy_2 = global.current_hp_enemy_2;
138
            global.current_hp_enemy_2 = 0;
139
            global.enemy_betrayed_2 = true;
140
            damage_type = "betrayed";
141
            instance_create(global.enemy_damage_x_2, global.enemy_damage_y_2, obj_text_damage_count);
142
            audio_play_sound(snd_monster_damage_hit_critical, 20, false);
143
        }
144
        else if (global.enemy_vulnerable_2 == true)
145
        {
146
            if ((arg0 == "Knife Single" && x == 319) || ((arg0 == "Gun Single" || arg0 == "Revolver Single") && b == 3.5) || ((arg0 == "Gun Multi" || arg0 == "Revolver Multi") && b == 3.5) || global.current_hp_enemy_2 <= global.attacking_damage_stat_critical_2)
147
            {
148
                global.last_hp_enemy_2 = global.current_hp_enemy_2;
149
                global.current_hp_enemy_2 -= global.attacking_damage_stat_critical_2;
150
                damage_type = "critical";
151
                instance_create(global.enemy_damage_x_2, global.enemy_damage_y_2, obj_text_damage_count);
152
                audio_play_sound(snd_monster_damage_hit_critical, 20, false);
153
            }
154
            else
155
            {
156
                global.last_hp_enemy_2 = global.current_hp_enemy_2;
157
                global.current_hp_enemy_2 -= global.attacking_damage_stat;
158
                damage_type = "normal";
159
                instance_create(global.enemy_damage_x_2, global.enemy_damage_y_2, obj_text_damage_count);
160
                audio_play_sound(snd_monster_damage_hit, 20, false);
161
            }
162
        }
163
        else
164
        {
165
            instance_create(global.enemy_damage_x_2, global.enemy_damage_y_2, obj_text_miss);
166
        }
167
    }
168
    else
169
    {
170
        instance_create(global.enemy_damage_x_2, global.enemy_damage_y_2, obj_text_miss);
171
    }
172
    instance_create(0, 0, obj_battle_enemy_attacking_code_2);
173
    if (instance_exists(obj_text_damage_count))
174
    {
175
        instance_create(obj_text_damage_count.x - 52, obj_text_damage_count.y + 26, obj_battle_hp_current_enemy_attacking_2);
176
        instance_create(obj_text_damage_count.x - 52, obj_text_damage_count.y + 26, obj_battle_hp_previous_enemy_attacking_2);
177
        instance_create(obj_text_damage_count.x - 52, obj_text_damage_count.y + 26, obj_battle_hp_max_enemy_attacking_2);
178
    }
179
    scr_determine_can_display_damage_ui
scr_determine_can_display_damage_ui

function scr_determine_can_display_damage_ui(arg0) { hp_ui_alpha = 1; damage_ui_alpha = 1; miss_ui_alpha = 1; if (arg0 == 1) { var game_mode = global.game_mode; var battle_enemy_name = global.battle_enemy_name; if (global.game_mode == "customs") { switch (battle_enemy_name) { default: } } else if (global.game_mode == "yellow") { switch (battle_enemy_name) { case "dummy training pacifist": hp_ui_alpha = 0; damage_ui_alpha = 0; break; default: } } } if (arg0 == 2) { var game_mode = global.game_mode; var battle_enemy_name = global.battle_enemy_name_2; if (global.game_mode == "customs") { switch (battle_enemy_name) { default: } } else if (global.game_mode == "yellow") { switch (battle_enemy_name) { default: } } } if (arg0 == 3) { var game_mode = global.game_mode; var battle_enemy_name = global.battle_enemy_name_3; if (global.game_mode == "customs") { switch (battle_enemy_name) { default: } } else if (global.game_mode == "yellow") { switch (battle_enemy_name) { default: } } } if (instance_exists(obj_battle_hp_enemy_attacking_parent)) { with (obj_battle_hp_enemy_attacking_parent) image_alpha = obj_target_bar_battle.hp_ui_alpha; } if (instance_exists(obj_text_damage_count)) { with (obj_text_damage_count) image_alpha = obj_target_bar_battle.damage_ui_alpha; } if (instance_exists(obj_text_miss)) { with (obj_text_miss) image_alpha = obj_target_bar_battle.miss_ui_alpha; } }
(2);
180
    if (global.current_hp_enemy_2 <= global.attacking_damage_stat_critical_2 && instance_exists(obj_text_damage_count))
181
        global.enemy_low_hp_2 = true;
182
    if (instance_exists(obj_text_fighting_parent))
183
        script_execute(scr_determine_attack_bonus);
184
}