Debugbro

Dungeon Beta Fix

Sep 29th, 2013
3,011
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Dungeon Beta fixes by Eearslya and Debugbro
  2. // Adapted from code by Orteil
  3. // User guide:
  4. // - Arrow Keys, Space and A button are used for dungeons as soon as you click Enter Dungeon
  5. // - Clicking "Exit" gives you back normal control over these keys
  6. // - Arrow keys for movement, Space for standing still a turn, "A" key for turning autopilot on/off
  7. // Bugfixes:
  8. // - Girlscout doesn't revert to Chip anymore
  9. // - Game shouldn't be frozen between two levels anymore
  10.  
  11. Game.handleButton = function(event) {
  12. dungeon = Game.Objects['Factory'].dungeon;
  13. hero = dungeon.hero;
  14. if(Game.Objects['Factory'].onSpecial==1) // Exiting dungeon gives you back your arrow key control
  15. {
  16. switch(event.keyCode) {
  17. case 38:hero.Move(0,-1);
  18. break;
  19. case 40:hero.Move(0,1);
  20. break;
  21. case 37:hero.Move(-1,0);
  22. break;
  23. case 39:hero.Move(1,0);
  24. break;
  25. case 32:hero.Move(0,0);
  26. break;
  27. case 65:if(dungeon.auto)
  28. {
  29. dungeon.auto=0;
  30. dungeon.timerWarmup=-1;
  31. Game.Popup("Autopilot disengaged");
  32. }
  33. else
  34. {
  35. dungeon.auto=1;
  36. dungeon.timer=0;
  37. dungeon.timerWarmup=0;
  38. Game.Popup("Autopilot engaged");
  39. }
  40. break;
  41. }
  42. event.preventDefault();
  43. }
  44. }
  45.  
  46. document.addEventListener('keydown', function(event) { Game.handleButton(event); });
  47.  
  48. TheDungeon = Game.Objects['Factory'].dungeon;
  49. TheDungeon.CompleteLevel=function() {
  50. TheDungeon.hero.Say('completion');
  51. TheDungeon.level++;
  52. TheDungeon.Generate();
  53. Game.HeroesById[TheDungeon.hero.id].EnterDungeon(TheDungeon,TheDungeon.map.entrance[0],TheDungeon.map.entrance[1]);
  54. TheDungeon.Draw();
  55. TheDungeon.Refresh();
  56. l('monsterSlot'+TheDungeon.id).style.visibility='hidden';
  57. l('hpMonster'+TheDungeon.id).style.width='100%';
  58. l('picHero'+TheDungeon.id).style.backgroundImage='url(img/'+TheDungeon.hero.portrait+'.png)';
  59. TheDungeon.UpdateLog()
  60. }
  61. TheDungeon.FailLevel=function() {
  62. TheDungeon.Log('Cookies made this run : '+Beautify(TheDungeon.cookiesMadeThisRun)+' | Monsters defeated this run : '+Beautify(TheDungeon.monstersKilledThisRun));
  63. TheDungeon.cookiesMadeThisRun=0;
  64. TheDungeon.monstersKilledThisRun=0;
  65. TheDungeon.level=0;
  66. TheDungeon.Generate();
  67. newhero=choose(Game.HeroesById);
  68. newhero.EnterDungeon(TheDungeon,TheDungeon.map.entrance[0],TheDungeon.map.entrance[1]);
  69. TheDungeon.Draw();
  70. TheDungeon.Refresh();
  71. l('monsterSlot'+TheDungeon.id).style.visibility='hidden';
  72. l('hpMonster'+TheDungeon.id).style.width='100%';
  73. l('picHero'+TheDungeon.id).style.backgroundImage='url(img/'+TheDungeon.hero.portrait+'.png)';
  74. TheDungeon.UpdateLog()
  75. }
RAW Paste Data