Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Enemy placements are decided inside the enemies code
  2. //All the enemy armors are added together here
  3. //When enemy dies, they empty their space in array here and gets removed after their death animation is played
  4. //There is two phase; attackPhase and defensePhase(!attackPhase)
  5. //And there is three situations; correct key, wrong key and timeout
  6. //If it's not timeout
  7. //Which goes like this: correct key -> attackPhase or attackPhase
  8. //Wrong key -> attackPhase or !attackPhase
  9. //Or it's timeout and either attackPhase or !attackPhase which gives the same result as
  10. //Wrong key -> attackPhase or !attackPhase
  11. baseArmor = 0;
  12. for (i = 0; i < array_length_1d(opponents)-1; i++)
  13. {
  14.     if instance_exists(opponents[i])
  15.     {
  16.         baseArmor += opponents[i].baseArmor;
  17.     }
  18. }
  19. //show_debug_message("Base Armor " + string(baseArmor));
  20. t = fightCounter.t;
  21. if keyboard_check_pressed(ord("G")) attackPhase = round(random(1));
  22. if attackPhase { global.typeToScreen = "Attack Phase"; } else { global.typeToScreen = "Defend Phase"; }
  23. if key == ord("J") && t >= 15 draw_sprite(spr_j, 0, global.cx + global.cw/2, global.cy + global.ch/3);
  24. if key == ord("K") && t >= 15 draw_sprite(spr_k, 0, global.cx + global.cw/2, global.cy + global.ch/3);
  25. if key == ord("L") && t >= 15 draw_sprite(spr_l, 0, global.cx + global.cw/2, global.cy + global.ch/3);
  26. if t >= 15 && t < 75 //Time space to press buttons
  27. {
  28.     if keyboard_check(vk_anykey)
  29.     {
  30.         if keyboard_key == key //Correct Key
  31.         {
  32.             key = round(random(randomNum));
  33.             if attackPhase //correct key
  34.             {
  35.                 with obj_mc attack = true;
  36.                 //if currentArmor > 0 currentArmor--;
  37.                 //show_debug_message("Current Armor " + string(currentArmor));
  38.                 //show_debug_message("Base Armor " + string(baseArmor));
  39.                 with opponents[target]
  40.                 {
  41.                     rumble = true;
  42.                     attack = false;
  43.                     //hp--;
  44.                     if hp <= 0 other.opponents[other.target] = noone;
  45.                    // show_debug_message("HP " + string(hp));
  46.                 }
  47.             }
  48.             else //defendPhase correct key
  49.             {
  50.                 currentArmor--;
  51.                 //show_debug_message("Current Armor " + string(currentArmor));
  52.                 //show_debug_message("Base Armor " + string(baseArmor));
  53.                 with opponents[target]
  54.                 {
  55.                     rumble = true;
  56.                 }
  57.                 if currentArmor <= 0
  58.                 { //Make it attackPhase
  59.                     attackPhase = true;
  60.                     with opponents[target]
  61.                     {
  62.                         x = global.cx + global.cw*.5 + other.target*10;
  63.                     }
  64.                     with obj_mc
  65.                     {
  66.                         dash = true;
  67.                         dashSpd = 13;
  68.                         //show_debug_message("Mc dash once");
  69.                     }
  70.                 }
  71.             }
  72.             fightCounter.t = 0;
  73.         }
  74.         else //Wrong Key
  75.         { //If attack phase, it becomes defense phase here, else player will get damage
  76.             key = round(random(randomNum));
  77.             with opponents[target]
  78.             {
  79.                 attack = true;
  80.                 image_index = 0;
  81.             }
  82.             with obj_mc
  83.             {
  84.                 attack = false;
  85.                 rumble = true;
  86.             }
  87.             currentArmor = baseArmor;
  88.             if attackPhase
  89.             { //Make it !attackPhase
  90.                 with opponents[target]
  91.                 {
  92.                     //dash = true;
  93.                     //dashSpd = -13;
  94.                     //show_debug_message("enemy dash");
  95.                 }
  96.                 with obj_mc
  97.                 {
  98.                     x = global.cx + global.cw*.25;
  99.                     //show_debug_message("Mc X inside the obj_fight " + string(x));
  100.                     //show_debug_message("deneme");
  101.                     //show_debug_message("Put mc to def");
  102.                 }
  103.                 attackPhase = false;
  104.             }
  105.             else
  106.             {
  107.                 with obj_mc health--;
  108.                 //show_debug_message(health);
  109.             }
  110.             fightCounter.t = 0;
  111.         }
  112.     }
  113. }
  114. else if t >= 75 //Timeout
  115. { //If attackPhase make it !attackPhase else player takes damage
  116.     key = round(random(randomNum));
  117.     with opponents[target]
  118.     {
  119.         attack = true;
  120.         image_index = 0;
  121.     }
  122.     with obj_mc
  123.     {
  124.         attack = false;
  125.         rumble = true;
  126.     }
  127.     currentArmor = baseArmor;
  128.     if attackPhase
  129.     { //Make it !attackPhase
  130.         with opponents[target]
  131.         {
  132.             //dash = true;
  133.             //dashSpd = -13;
  134.                     //show_debug_message("enemy dash");
  135.         }
  136.         with obj_mc
  137.         {
  138.             x = global.cx + global.cw*.25;
  139.             //show_debug_message("Put mc to def");
  140.         }
  141.         attackPhase = false;
  142.     }
  143.     else
  144.     {
  145.         with obj_mc health--;
  146.         show_debug_message(health);
  147.     }
  148.     fightCounter.t = 0;
  149. }
  150. /*switch key
  151. {
  152.     case 0:
  153.     if t >= 15
  154.     {
  155.         draw_sprite(spr_j, 0, global.cx + global.cw/2, global.cy + global.ch/3);
  156.         if keyboard_check_pressed(ord("J"))
  157.         {
  158.             key = round(random(randomNum));
  159.             if attackPhase scr_animationManager("mc", "attack");
  160.             fightCounter.t = 0;
  161.             //else scr_animationManager("mc", "defend");
  162.             //deal damage
  163.         }
  164.         else if keyboard_check(vk_anykey)
  165.         {
  166.             if attackPhase
  167.             {
  168.                 attackPhase = false;
  169.                 fightCounter.t = 0;
  170.             }
  171.             else
  172.             {
  173.                 attackPhase = true;
  174.                 fightCounter.t = 0;
  175.                 //damage player
  176.             }
  177.         }
  178.     }
  179.     else if t >= 30
  180.     {
  181.         if attackPhase { attackPhase = false; defendPhase = true; }
  182.         else { attackPhase = true; defendPhase = false; }
  183.     }
  184.         show_debug_message("Draw J");
  185.     break;
  186.  
  187.     case 1:
  188.     draw_sprite(spr_k, 0, global.cx + global.cw/2, global.cy + global.ch/3);
  189.     if keyboard_check_pressed(ord("K"))
  190.     {
  191.         key = round(random(randomNum));
  192.         if attackPhase scr_animationManager("mc", "attack");
  193.         //else scr_animationManager("mc", "defend");
  194.         //deal damage
  195.     }
  196.     show_debug_message("Draw K");
  197.     break;
  198.    
  199.     case 2:
  200.     draw_sprite(spr_l, 0, global.cx + global.cw/2, global.cy + global.ch/3);
  201.     if keyboard_check_pressed(ord("L"))
  202.     {
  203.         key = round(random(randomNum));
  204.         if attackPhase scr_animationManager("mc", "attack");
  205.         //else scr_animationManager("mc", "defend");
  206.         //deal damage
  207.     }
  208.     show_debug_message("Draw L");
  209.     break;
  210. }*/
  211. if key == 0 key = ord("J");
  212. if key == 1 key = ord("K");
  213. if key == 2 key = ord("L");
  214. if !instance_exists(opponents[target]) { target++; show_debug_message(target); }
  215. if target > 3
  216. {
  217.     instance_destroy();
  218.     audio_pause_sound(bgm_fight);
  219.     global.noInput = false;
  220.     global.manualCamera = false;
  221.     show_debug_message("Destroy obj_fight");
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement