Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Enemy placements are decided inside the enemies code
- //All the enemy armors are added together here
- //When enemy dies, they empty their space in array here and gets removed after their death animation is played
- //There is two phase; attackPhase and defensePhase(!attackPhase)
- //And there is three situations; correct key, wrong key and timeout
- //If it's not timeout
- //Which goes like this: correct key -> attackPhase or attackPhase
- //Wrong key -> attackPhase or !attackPhase
- //Or it's timeout and either attackPhase or !attackPhase which gives the same result as
- //Wrong key -> attackPhase or !attackPhase
- baseArmor = 0;
- for (i = 0; i < array_length_1d(opponents)-1; i++)
- {
- if instance_exists(opponents[i])
- {
- baseArmor += opponents[i].baseArmor;
- }
- }
- //show_debug_message("Base Armor " + string(baseArmor));
- t = fightCounter.t;
- if keyboard_check_pressed(ord("G")) attackPhase = round(random(1));
- if attackPhase { global.typeToScreen = "Attack Phase"; } else { global.typeToScreen = "Defend Phase"; }
- if key == ord("J") && t >= 15 draw_sprite(spr_j, 0, global.cx + global.cw/2, global.cy + global.ch/3);
- if key == ord("K") && t >= 15 draw_sprite(spr_k, 0, global.cx + global.cw/2, global.cy + global.ch/3);
- if key == ord("L") && t >= 15 draw_sprite(spr_l, 0, global.cx + global.cw/2, global.cy + global.ch/3);
- if t >= 15 && t < 75 //Time space to press buttons
- {
- if keyboard_check(vk_anykey)
- {
- if keyboard_key == key //Correct Key
- {
- key = round(random(randomNum));
- if attackPhase //correct key
- {
- with obj_mc attack = true;
- //if currentArmor > 0 currentArmor--;
- //show_debug_message("Current Armor " + string(currentArmor));
- //show_debug_message("Base Armor " + string(baseArmor));
- with opponents[target]
- {
- rumble = true;
- attack = false;
- //hp--;
- if hp <= 0 other.opponents[other.target] = noone;
- // show_debug_message("HP " + string(hp));
- }
- }
- else //defendPhase correct key
- {
- currentArmor--;
- //show_debug_message("Current Armor " + string(currentArmor));
- //show_debug_message("Base Armor " + string(baseArmor));
- with opponents[target]
- {
- rumble = true;
- }
- if currentArmor <= 0
- { //Make it attackPhase
- attackPhase = true;
- with opponents[target]
- {
- x = global.cx + global.cw*.5 + other.target*10;
- }
- with obj_mc
- {
- dash = true;
- dashSpd = 13;
- //show_debug_message("Mc dash once");
- }
- }
- }
- fightCounter.t = 0;
- }
- else //Wrong Key
- { //If attack phase, it becomes defense phase here, else player will get damage
- key = round(random(randomNum));
- with opponents[target]
- {
- attack = true;
- image_index = 0;
- }
- with obj_mc
- {
- attack = false;
- rumble = true;
- }
- currentArmor = baseArmor;
- if attackPhase
- { //Make it !attackPhase
- with opponents[target]
- {
- //dash = true;
- //dashSpd = -13;
- //show_debug_message("enemy dash");
- }
- with obj_mc
- {
- x = global.cx + global.cw*.25;
- //show_debug_message("Mc X inside the obj_fight " + string(x));
- //show_debug_message("deneme");
- //show_debug_message("Put mc to def");
- }
- attackPhase = false;
- }
- else
- {
- with obj_mc health--;
- //show_debug_message(health);
- }
- fightCounter.t = 0;
- }
- }
- }
- else if t >= 75 //Timeout
- { //If attackPhase make it !attackPhase else player takes damage
- key = round(random(randomNum));
- with opponents[target]
- {
- attack = true;
- image_index = 0;
- }
- with obj_mc
- {
- attack = false;
- rumble = true;
- }
- currentArmor = baseArmor;
- if attackPhase
- { //Make it !attackPhase
- with opponents[target]
- {
- //dash = true;
- //dashSpd = -13;
- //show_debug_message("enemy dash");
- }
- with obj_mc
- {
- x = global.cx + global.cw*.25;
- //show_debug_message("Put mc to def");
- }
- attackPhase = false;
- }
- else
- {
- with obj_mc health--;
- show_debug_message(health);
- }
- fightCounter.t = 0;
- }
- /*switch key
- {
- case 0:
- if t >= 15
- {
- draw_sprite(spr_j, 0, global.cx + global.cw/2, global.cy + global.ch/3);
- if keyboard_check_pressed(ord("J"))
- {
- key = round(random(randomNum));
- if attackPhase scr_animationManager("mc", "attack");
- fightCounter.t = 0;
- //else scr_animationManager("mc", "defend");
- //deal damage
- }
- else if keyboard_check(vk_anykey)
- {
- if attackPhase
- {
- attackPhase = false;
- fightCounter.t = 0;
- }
- else
- {
- attackPhase = true;
- fightCounter.t = 0;
- //damage player
- }
- }
- }
- else if t >= 30
- {
- if attackPhase { attackPhase = false; defendPhase = true; }
- else { attackPhase = true; defendPhase = false; }
- }
- show_debug_message("Draw J");
- break;
- case 1:
- draw_sprite(spr_k, 0, global.cx + global.cw/2, global.cy + global.ch/3);
- if keyboard_check_pressed(ord("K"))
- {
- key = round(random(randomNum));
- if attackPhase scr_animationManager("mc", "attack");
- //else scr_animationManager("mc", "defend");
- //deal damage
- }
- show_debug_message("Draw K");
- break;
- case 2:
- draw_sprite(spr_l, 0, global.cx + global.cw/2, global.cy + global.ch/3);
- if keyboard_check_pressed(ord("L"))
- {
- key = round(random(randomNum));
- if attackPhase scr_animationManager("mc", "attack");
- //else scr_animationManager("mc", "defend");
- //deal damage
- }
- show_debug_message("Draw L");
- break;
- }*/
- if key == 0 key = ord("J");
- if key == 1 key = ord("K");
- if key == 2 key = ord("L");
- if !instance_exists(opponents[target]) { target++; show_debug_message(target); }
- if target > 3
- {
- instance_destroy();
- audio_pause_sound(bgm_fight);
- global.noInput = false;
- global.manualCamera = false;
- show_debug_message("Destroy obj_fight");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement