Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_scr_damage_determination_enemy

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

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

var _temp_local_var_2, _temp_local_var_3, _temp_local_var_4, _temp_local_var_5, _temp_local_var_6; function scr_determine_can_display_damage_ui(argument0) //gml_Script_scr_determine_can_display_damage_ui { hp_ui_alpha = 1 damage_ui_alpha = 1 miss_ui_alpha = 1 if (argument0 == 1) { var game_mode = global.game_mode var battle_enemy_name = global.battle_enemy_name if (global.game_mode == "customs") var _temp_local_var_2 = battle_enemy_name 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 (argument0 == 2) { game_mode = global.game_mode battle_enemy_name = global.battle_enemy_name_2 if (global.game_mode == "customs") var _temp_local_var_3 = battle_enemy_name else if (global.game_mode == "yellow") var _temp_local_var_6 = battle_enemy_name } if (argument0 == 3) { game_mode = global.game_mode battle_enemy_name = global.battle_enemy_name_3 if (global.game_mode == "customs") var _temp_local_var_4 = battle_enemy_name else if (global.game_mode == "yellow") var _temp_local_var_5 = battle_enemy_name } 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 } }
(1)
183
    if (global.current_hp_enemy <= global.attacking_damage_stat_critical && instance_exists(obj_text_damage_count))
184
        global.enemy_low_hp = true
185
    if instance_exists(obj_text_fighting_parent)
186
        script_execute(gml_Script_scr_determine_attack_bonus)
187
}