| 1 |
if (live_call()) |
| 2 |
return global.live_result; |
| 3 |
script_execute(scr_controls_battle_heart_red); |
| 4 |
charge_percentage = charge_time / charge_time_max; |
| 5 |
x_previous = x; |
| 6 |
y_previous = y; |
| 7 |
move_x = key_left + key_right; |
| 8 |
move_y = key_down + key_up; |
| 9 |
hsp = move_x * walk_speed; |
| 10 |
vsp = move_y * walk_speed; |
| 11 |
if (is_dashing) |
| 12 |
{ |
| 13 |
var ghost = instance_create_depth(x, y, depth, obj_dash_ghost); |
| 14 |
ghost.sprite_index = base_sprite; |
| 15 |
hsp = move_x_dash * dash_speed; |
| 16 |
vsp = move_y_dash * dash_speed; |
| 17 |
dash_timer--; |
| 18 |
if (dash_timer <= 0) |
| 19 |
is_dashing = false; |
| 20 |
} |
| 21 |
else |
| 22 |
{ |
| 23 |
dash_timer = dash_distance; |
| 24 |
} |
| 25 |
hsp += hsp_factor; |
| 26 |
vsp += vsp_factor; |
| 27 |
var left_boundary, right_boundary, top_boundary, bottom_boundary; |
| 28 |
if (room == rm_battle_flowey_phase_2) |
| 29 |
{ |
| 30 |
right_boundary = room_width; |
| 31 |
left_boundary = 0; |
| 32 |
top_boundary = 260; |
| 33 |
bottom_boundary = room_height; |
| 34 |
} |
| 35 |
else |
| 36 |
{ |
| 37 |
right_boundary = obj_dialogue_box_battle_transformation_any.bbox_right - 4; |
| 38 |
left_boundary = obj_dialogue_box_battle_transformation_any.bbox_left + 4; |
| 39 |
top_boundary = obj_dialogue_box_battle_transformation_any.bbox_top + 4; |
| 40 |
bottom_boundary = obj_dialogue_box_battle_transformation_any.bbox_bottom - 4; |
| 41 |
} |
| 42 |
if (sign(hsp) == -1 && (bbox_left + hsp) <= left_boundary) |
| 43 |
{ |
| 44 |
while ((bbox_left + sign(hsp)) > left_boundary) |
| 45 |
x += sign(hsp); |
| 46 |
is_dashing = false; |
| 47 |
hsp = 0; |
| 48 |
} |
| 49 |
else if (sign(hsp) == 1 && (bbox_right + hsp) >= right_boundary) |
| 50 |
{ |
| 51 |
while ((bbox_right + sign(hsp)) < right_boundary) |
| 52 |
x += sign(hsp); |
| 53 |
is_dashing = false; |
| 54 |
hsp = 0; |
| 55 |
} |
| 56 |
x += hsp; |
| 57 |
if (sign(vsp) == -1 && (bbox_top + vsp) <= top_boundary) |
| 58 |
{ |
| 59 |
while ((bbox_top + sign(vsp)) > top_boundary) |
| 60 |
y += sign(vsp); |
| 61 |
is_dashing = false; |
| 62 |
vsp = 0; |
| 63 |
} |
| 64 |
else if (sign(vsp) == 1 && (bbox_bottom + vsp) >= bottom_boundary) |
| 65 |
{ |
| 66 |
while ((bbox_bottom + sign(vsp)) < bottom_boundary) |
| 67 |
y += sign(vsp); |
| 68 |
is_dashing = false; |
| 69 |
vsp = 0; |
| 70 |
} |
| 71 |
y += vsp; |
| 72 |
var collider_id = instance_place(x, y + vsp, obj_martlet_attack_glass); |
| 73 |
if (collider_id != -4) |
| 74 |
{ |
| 75 |
if (vsp != 0) |
| 76 |
{ |
| 77 |
} |
| 78 |
} |
| 79 |
obj_heart_red_hitbox.x = x; |
| 80 |
obj_heart_red_hitbox.y = y; |
| 81 |
if (instance_exists(obj_heart_battle_effect_glow)) |
| 82 |
{ |
| 83 |
obj_heart_battle_effect_glow.x = x; |
| 84 |
obj_heart_battle_effect_glow.y = y; |
| 85 |
} |
| 86 |
if (moveable == true && global.current_sp_self > 0) |
| 87 |
{ |
| 88 |
var can_trail = false; |
| 89 |
trail_cc_current += 1; |
| 90 |
if (trail_cc_current >= trail_cc_max) |
| 91 |
{ |
| 92 |
can_trail = true; |
| 93 |
trail_cc_current = 0; |
| 94 |
} |
| 95 |
if (can_trail == true) |
| 96 |
{ |
| 97 |
ds_list_add(x_list, x); |
| 98 |
ds_list_add(y_list, y); |
| 99 |
while (ds_list_size(x_list) > max_points_trail) |
| 100 |
{ |
| 101 |
ds_list_delete(x_list, 0); |
| 102 |
ds_list_delete(y_list, 0); |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
else if (ds_list_size(x_list) > 0) |
| 107 |
{ |
| 108 |
ds_list_clear(x_list); |
| 109 |
} |
| 110 |
if (room == rm_battle_flowey_phase_2) |
| 111 |
{ |
| 112 |
if (sprite_index == spr_heart_yellow_down) |
| 113 |
{ |
| 114 |
base_sprite = 1661; |
| 115 |
var dash_disable = true; |
| 116 |
if (instance_exists(obj_flowey_battle_final)) |
| 117 |
{ |
| 118 |
for (var i = 0; i < array_length(obj_flowey_battle_final.petal_alive); i++) |
| 119 |
{ |
| 120 |
if (obj_flowey_battle_final.petal_alive[i] == false) |
| 121 |
dash_disable = false; |
| 122 |
} |
| 123 |
} |
| 124 |
if (dash_disable == true) |
| 125 |
{ |
| 126 |
is_dashing = false; |
| 127 |
can_dash = false; |
| 128 |
} |
| 129 |
} |
| 130 |
else |
| 131 |
{ |
| 132 |
base_sprite = 1662; |
| 133 |
} |
| 134 |
} |
| 135 |
if ((abs(move_x) + abs(move_y)) == 0) |
| 136 |
{ |
| 137 |
if (keyboard_multicheck_pressed(1)) |
| 138 |
dash_buffered = true; |
| 139 |
if (keyboard_multicheck_released(1) && dash_buffered == true) |
| 140 |
dash_buffered = false; |
| 141 |
} |
| 142 |
if ((keyboard_multicheck_pressed(1) || dash_buffered) && moveable == true && can_dash == true && (abs(move_x) + abs(move_y)) != 0) |
| 143 |
{ |
| 144 |
audio_play_sound(snd_yellow_soul_dash, 1, 0); |
| 145 |
dash_overlay = 1.1; |
| 146 |
move_x_dash = move_x; |
| 147 |
move_y_dash = move_y; |
| 148 |
dash_grace = dash_grace_max; |
| 149 |
is_dashing = true; |
| 150 |
dash_buffered = false; |
| 151 |
can_dash = false; |
| 152 |
} |
| 153 |
if (!can_dash && !is_dashing) |
| 154 |
{ |
| 155 |
if (dash_grace > 0) |
| 156 |
dash_grace--; |
| 157 |
if (dash_delay > 0) |
| 158 |
{ |
| 159 |
dash_delay--; |
| 160 |
} |
| 161 |
else |
| 162 |
{ |
| 163 |
dash_grace = 0; |
| 164 |
dash_delay = dash_delay_max; |
| 165 |
can_dash = true; |
| 166 |
} |
| 167 |
} |
| 168 |
if (keyboard_multicheck_released(1) && is_dashing && can_cancel_dash) |
| 169 |
is_dashing = false; |
| 170 |
if (dash_overlay > 0) |
| 171 |
dash_overlay -= 0.1; |
| 172 |
shoot_delay = 10; |
| 173 |
if (shoot_buffer <= 0) |
| 174 |
{ |
| 175 |
if (keyboard_multicheck_pressed(0)) |
| 176 |
shoot_buffer = 10; |
| 177 |
} |
| 178 |
else |
| 179 |
{ |
| 180 |
shoot_buffer--; |
| 181 |
} |
| 182 |
var turn_angle_target_final = turn_angle_target - 90; |
| 183 |
switch (turn_state) |
| 184 |
{ |
| 185 |
case 0: |
| 186 |
if (image_angle != turn_angle_target_final) |
| 187 |
turn_state += 1; |
| 188 |
break; |
| 189 |
case 1: |
| 190 |
image_xscale += 0.25; |
| 191 |
image_yscale += 0.25; |
| 192 |
if (image_xscale > 1.5) |
| 193 |
turn_state += 1; |
| 194 |
break; |
| 195 |
case 2: |
| 196 |
image_angle += (angle_difference(turn_angle_target_final, image_angle) * 0.2); |
| 197 |
if (image_xscale > 1) |
| 198 |
image_xscale -= 0.2; |
| 199 |
else |
| 200 |
image_xscale = 1; |
| 201 |
if (angle_difference(image_angle, turn_angle_target_final) < 1) |
| 202 |
{ |
| 203 |
image_angle = turn_angle_target_final; |
| 204 |
image_xscale = 1; |
| 205 |
turn_state = 0; |
| 206 |
show_debug_message("LOCKED " + string(turn_angle_target_final)); |
| 207 |
} |
| 208 |
image_yscale = image_xscale; |
| 209 |
break; |
| 210 |
} |
| 211 |
if (turn_state > 0) |
| 212 |
{ |
| 213 |
if (instance_exists(obj_heart_yellow_shot_blast)) |
| 214 |
{ |
| 215 |
} |
| 216 |
} |
| 217 |
if (instance_exists(obj_heart_yellow_shot_blast)) |
| 218 |
{ |
| 219 |
can_shoot = false; |
| 220 |
alarm[1] = shoot_delay; |
| 221 |
} |
| 222 |
if (keyboard_multicheck_pressed(2) && global.option_autoshoot) |
| 223 |
{ |
| 224 |
if (global.autofire_on) |
| 225 |
global.autofire_on = false; |
| 226 |
else |
| 227 |
global.autofire_on = true; |
| 228 |
} |
| 229 |
if (global.option_autoshoot == false) |
| 230 |
global.autofire_on = false; |
| 231 |
|
| 232 |
function fireCheck() |
| 233 |
{ |
| 234 |
if (global.autofire_on == true || (global.autofire_on == false && keyboard_multicheck_pressed(0))) |
| 235 |
return true; |
| 236 |
return false; |
| 237 |
} |
| 238 |
|
| 239 |
if ((fireCheck() || shoot_buffer > 0) && sprite_index != spr_heart_yellow_down && moveable == true && can_shoot == true && !blast_is_firing && !is_charging) |
| 240 |
{ |
| 241 |
shoot_buffer = 0; |
| 242 |
sprite_index = spr_heart_yellow_shoot; |
| 243 |
image_index = 0; |
| 244 |
image_speed = 1; |
| 245 |
var yy = y - 6; |
| 246 |
var xx = x + 0.5; |
| 247 |
if (image_angle == 90 || image_angle == 270) |
| 248 |
{ |
| 249 |
yy = y; |
| 250 |
xx = x; |
| 251 |
} |
| 252 |
if (image_angle == 180) |
| 253 |
yy = y + 6; |
| 254 |
var shot = instance_create_depth(xx, yy, -10000, obj_heart_yellow_shot); |
| 255 |
shot.direction = image_angle + 90; |
| 256 |
shot.image_angle = image_angle; |
| 257 |
can_shoot = false; |
| 258 |
alarm[1] = shoot_delay; |
| 259 |
} |
| 260 |
if (keyboard_multicheck(0) && !is_charging && sprite_index != spr_heart_yellow_down && moveable == true && !blast_is_firing && can_charge == true) |
| 261 |
{ |
| 262 |
if (!alarm[2]) |
| 263 |
alarm[2] = 7; |
| 264 |
} |
| 265 |
if (keyboard_multicheck_released(0) || keyboard_multicheck_pressed(2)) |
| 266 |
{ |
| 267 |
alarm[2] = -1; |
| 268 |
if (is_charging == true) |
| 269 |
{ |
| 270 |
is_charging = false; |
| 271 |
charge_time = charge_time_max; |
| 272 |
sprite_index = spr_heart_yellow_up; |
| 273 |
image_index = 0; |
| 274 |
image_speed = 0; |
| 275 |
if (is_charged == true) |
| 276 |
{ |
| 277 |
if (charged_shot_type == 1) |
| 278 |
{ |
| 279 |
var yy = y - 6; |
| 280 |
var xx = x + 0.5; |
| 281 |
if (image_angle == 90 || image_angle == 270) |
| 282 |
{ |
| 283 |
yy = y; |
| 284 |
xx = x; |
| 285 |
} |
| 286 |
var shot_big = instance_create_depth(xx, yy, -10000, obj_heart_yellow_shot_big); |
| 287 |
shot_big.direction = image_angle + 90; |
| 288 |
shot_big.image_angle = image_angle; |
| 289 |
is_charged = false; |
| 290 |
can_shoot = false; |
| 291 |
alarm[1] = shoot_delay; |
| 292 |
sprite_index = spr_heart_yellow_shoot; |
| 293 |
image_index = 0; |
| 294 |
image_speed = 1; |
| 295 |
} |
| 296 |
else if (charged_shot_type == 2) |
| 297 |
{ |
| 298 |
var shot_big = instance_create_depth(x, y, -10000, obj_heart_yellow_shot_blast); |
| 299 |
var image_angle_final = turn_angle_target_final; |
| 300 |
shot_big.direction = image_angle_final + 90; |
| 301 |
shot_big.image_angle = image_angle_final; |
| 302 |
is_charged = false; |
| 303 |
blast_is_firing = true; |
| 304 |
sprite_index = spr_heart_yellow_shoot; |
| 305 |
image_index = 0; |
| 306 |
image_speed = 0; |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
} |
| 311 |
if (is_charging) |
| 312 |
{ |
| 313 |
if (!audio_is_playing(snd_chargeshot_charge)) |
| 314 |
{ |
| 315 |
charge_sound = audio_play_sound(snd_chargeshot_charge, 1, 1); |
| 316 |
audio_sound_gain(charge_sound, 0.8, 0); |
| 317 |
audio_sound_pitch(charge_sound, 0.5); |
| 318 |
} |
| 319 |
if (charge_time > 0) |
| 320 |
{ |
| 321 |
charge_time -= 1; |
| 322 |
} |
| 323 |
else if (!is_charged) |
| 324 |
{ |
| 325 |
var ready_sound = audio_play_sound(snd_undertale_flash, 1, 0); |
| 326 |
audio_sound_gain(ready_sound, 0.5, 0); |
| 327 |
audio_sound_gain(charge_sound, 0, 1000); |
| 328 |
is_charged = true; |
| 329 |
sprite_index = spr_heart_yellow_ready; |
| 330 |
image_index = 0; |
| 331 |
image_speed = 1; |
| 332 |
} |
| 333 |
} |
| 334 |
else |
| 335 |
{ |
| 336 |
audio_stop_sound(charge_sound); |
| 337 |
is_charged = false; |
| 338 |
if (sprite_index == spr_heart_yellow_ready) |
| 339 |
{ |
| 340 |
sprite_index = spr_heart_yellow_up; |
| 341 |
image_index = 0; |
| 342 |
image_speed = 0; |
| 343 |
} |
| 344 |
} |
| 345 |
if (audio_is_playing(charge_sound)) |
| 346 |
{ |
| 347 |
var pitch_original = audio_sound_get_pitch(charge_sound); |
| 348 |
if (pitch_original < 0.99) |
| 349 |
audio_sound_pitch(charge_sound, 1 - (0.5 * charge_percentage)); |
| 350 |
else |
| 351 |
audio_sound_pitch(charge_sound, 1); |
| 352 |
} |
| 353 |
if (blast_is_firing && !instance_exists(obj_heart_yellow_shot_blast)) |
| 354 |
{ |
| 355 |
blast_is_firing = false; |
| 356 |
sprite_index = spr_heart_yellow_up; |
| 357 |
image_index = 0; |
| 358 |
image_speed = 0; |
| 359 |
} |
| 360 |
event_user(15); |