ice_mountain.nut 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. print("ice_mountain.nut loaded\n");
  2. //INITIALIZATION OF STATE VARIABLES
  3. key_names <- ["pink" "green" "red" "yellow" "darkness" "unlicensed" "star"]
  4. if(!("keys" in state)){
  5. state.keys <- {};
  6. foreach(name in key_names){
  7. state.keys[name] <- false;
  8. }
  9. print("key state initialized\n");
  10. }
  11. status <- state.keys;
  12. function set_darkness(night){
  13. dark.fade(night ? 0.6 : 0, 1);
  14. status.darkness <- night;
  15. save_keys();
  16. print("dark "+night+"\n");
  17. }
  18. function set_unlicensed(under){
  19. if(true||!(under && status.unlicensed)){
  20. speed <- 0.5;
  21. pathing.fade(under ? 0 : 1, speed);
  22. land_detail_far.fade(under ? 0 : 1, speed);
  23. land_detail_near.fade(under ? 0 : 1, speed);
  24. foreground_far.fade(under ? 0 : 1, speed);
  25. foreground_near.fade(under ? 0 : 1, speed);
  26. map.fade(under ? 0 : 1, speed);
  27. exit.fade(under ? 0 : (outpath ? 1 : 1), speed);
  28. noexit.fade(under ? 0 : (outpath ? 0 : 0), speed);
  29. u_pathing.fade(under ? 1 : 0, speed);
  30. u_map.fade(under ? 1 : 0, speed);
  31. u_background.fade(under ? 1 : 0, speed);
  32. u_foreground.fade(under ? 1 : 0, speed);
  33. status.unlicensed <- under;
  34. save_keys();
  35. print("un "+under+"\n");
  36. play_music(under ? "music/voc-night.music" : "music/voc-daytime2.music");
  37. }
  38. }
  39. function find(crystal){
  40. if(!status[crystal]){
  41. status[crystal] <- true;
  42. play_sound("sounds/upgrade.wav");
  43. save_keys();
  44. } else{
  45. play_sound("sounds/ticking.wav");
  46. }
  47. }
  48. function query(item){return status[item];}
  49. function check(crystal){return (status.green && status.yellow && status.orange && status.pink);}
  50. function set_bonus(){
  51. status.star <- true;
  52. wait(0.2);
  53. indicator.set_visible(true);
  54. save_keys();
  55. play_sound("sounds/invincible_start.ogg");
  56. print("invincibility mode set\n");
  57. }
  58. function fire_bonus(){
  59. Tux.deactivate();
  60. Tux.add_bonus("fireflower");
  61. play_sound("sounds/fire-flower.wav");
  62. print("fire bonus added\n");
  63. wait(1);
  64. Effect.fade_out(2);
  65. wait(2);
  66. Level.finish(true);
  67. }
  68. function ice_bonus(){
  69. Tux.deactivate();
  70. Tux.add_bonus("iceflower");
  71. play_sound("sounds/fire-flower.wav");
  72. print("ice bonus added\n");
  73. wait(1);
  74. Effect.fade_out(2);
  75. wait(2);
  76. Level.finish(true);
  77. }
  78. function save_keys(){state.keys <- status;}
  79. function reset_keys(){
  80. foreach(name in key_names){
  81. status[name] <- false;
  82. }
  83. save_keys();
  84. }
  85. indicator <- FloatingImage("images/powerups/star/star.sprite");
  86. indicator.set_anchor_point(ANCHOR_TOP_LEFT);
  87. indicator.set_pos(5, 5);
  88. indicator.set_visible(query("star"));
  89. if(status.star){
  90. if(!("map" in this)){
  91. Tux.make_invincible();}
  92. else{
  93. status.star <- false;
  94. indicator.set_visible(false);
  95. save_keys();
  96. print("invincibility mode deactivated\n");
  97. }
  98. }
  99. if("map" in this){
  100. outpath <- state.worlds["levels/pre_git_bugtracker_worldmap/worldmap.stwm"].levels["sever_escape.stl"].solved;
  101. set_darkness(status.darkness);
  102. set_unlicensed(status.unlicensed);
  103. wait(1);
  104. if(!status.unlicensed){
  105. exit.fade(outpath ? 1 : 0, 0);
  106. noexit.fade(outpath ? 0 : 1, 0);
  107. }
  108. print("map set\n");
  109. }