Advertisement
Jhynjhiruu

General array lookup (parts of)

Mar 19th, 2018
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package sponsored
  2. {
  3.    import com.newgrounds.API;
  4.    import com.newgrounds.components.MedalPopup;
  5.    import misc.Items;
  6.    import net.flashpunk.FP;
  7.    import net.flashpunk.Sfx;
  8.    
  9.    public class NewgroundsAPI
  10.    {
  11.        
  12.      
  13.       private var medal_popup:MedalPopup;
  14.      
  15.       private var _unlocked_coins_medal:Boolean = false;
  16.      
  17.       private var _unlock_box_break_medal:Boolean = false;
  18.      
  19.       public function NewgroundsAPI()
  20.       {
  21.          super();
  22.          this.medal_popup = new MedalPopup();
  23.          this.medal_popup.x = 20;
  24.          this.medal_popup.y = 580 - this.medal_popup.height;
  25.          FP.stage.addChild(this.medal_popup);
  26.       }
  27.      
  28.       public function CheckAllMedals() : void
  29.       {
  30.          this.MaxHPPlusPlus();
  31.          this.MoonStoneGet();
  32.          this.InventoryCheckForMedals(3);
  33.          this._SaveIndexCheckMedalsBackup();
  34.          this.InnSleepMedalCheck();
  35.          this.CoinAddCheckMedal(0);
  36.          this.BoxBreakCheckMedal(0);
  37.          this.EatFoodCheckMedal(21,true);
  38.          this._BestiaryMedalCheckBackup();
  39.          this._BeatGameBackupCheck();
  40.       }
  41.      
  42.       public function MaxHPPlusPlus() : void
  43.       {
  44.          if(FP.game_world.player.max_hp >= 99)
  45.          {
  46.             API.unlockMedal("Diamond Skin");
  47.          }
  48.          if(FP.game_world.player.max_hp >= 40)
  49.          {
  50.             API.unlockMedal("Iron Skin");
  51.          }
  52.       }
  53.      
  54.       public function MoonStoneGet() : void
  55.       {
  56.          var _loc1_:int = FP.game_world.local_save.space_rocks;
  57.          if(_loc1_ >= 42)
  58.          {
  59.             API.unlockMedal("Number 42");
  60.          }
  61.          if(_loc1_ >= 40)
  62.          {
  63.             API.unlockMedal("Master Moon Stone Hunter");
  64.          }
  65.          if(_loc1_ >= 20)
  66.          {
  67.             API.unlockMedal("Experienced Moon Stone Hunter");
  68.          }
  69.          if(_loc1_ >= 5)
  70.          {
  71.             API.unlockMedal("Novice Moon Stone Hunter");
  72.          }
  73.       }
  74.      
  75.       public function InventoryCheckForMedals(param1:int) : void
  76.       {
  77.          var _loc2_:Items = FP.game_world.player.items;
  78.          if(!_loc2_.Contains(1))
  79.          {
  80.             API.unlockMedal("Big Bag");
  81.          }
  82.          if(_loc2_.Contains(11))
  83.          {
  84.             API.unlockMedal("It\'s dangerous to go alone!");
  85.          }
  86.          if(_loc2_.Contains(61) && _loc2_.Contains(42) && _loc2_.Contains(60) && _loc2_.Contains(59) && _loc2_.Contains(13) && _loc2_.Contains(12) && _loc2_.Contains(23))
  87.          {
  88.             API.unlockMedal("Most Dangerous Arsenal");
  89.          }
  90.       }
  91.      
  92.       private function _SaveIndexCheckMedalsBackup() : void
  93.       {
  94.          if(FP.saver.CheckGeneralArray(316))
  95.          {
  96.             API.unlockMedal("Repentance");
  97.          }
  98.          if(FP.saver.CheckGeneralArray(122))
  99.          {
  100.             API.unlockMedal("Robin Hood?");
  101.          }
  102.          if(FP.saver.CheckGeneralArray(310))
  103.          {
  104.             API.unlockMedal("Bearer of Bad News");
  105.          }
  106.          if(FP.saver.CheckGeneralArray(311))
  107.          {
  108.             API.unlockMedal("Good Friend");
  109.          }
  110.          if(FP.saver.CheckGeneralArray(345))
  111.          {
  112.             API.unlockMedal("Explorer");
  113.          }
  114.          if(FP.saver.CheckGeneralArray(313))
  115.          {
  116.             API.unlockMedal("Exterminator");
  117.          }
  118.          if(FP.saver.CheckGeneralArray(390))
  119.          {
  120.             API.unlockMedal("Last Song of Earth");
  121.          }
  122.       }
  123.      
  124.       public function SaveIndexCheckMedals(param1:int) : void
  125.       {
  126.          if(param1 == 316)
  127.          {
  128.             API.unlockMedal("Repentance");
  129.          }
  130.          else if(param1 == 122)
  131.          {
  132.             API.unlockMedal("Robin Hood?");
  133.          }
  134.          else if(param1 == 310)
  135.          {
  136.             API.unlockMedal("Bearer of Bad News");
  137.          }
  138.          else if(param1 == 311)
  139.          {
  140.             API.unlockMedal("Good Friend");
  141.          }
  142.          else if(param1 == 345)
  143.          {
  144.             API.unlockMedal("Explorer");
  145.          }
  146.          else if(param1 == 313)
  147.          {
  148.             API.unlockMedal("Exterminator");
  149.          }
  150.          else if(param1 == 390)
  151.          {
  152.             API.unlockMedal("Last Song of Earth");
  153.          }
  154.       }
  155.      
  156.       public function InnSleepMedalCheck() : void
  157.       {
  158.          var _loc1_:Array = FP.game_world.local_save.general;
  159.          var _loc2_:int = 391;
  160.          while(_loc2_ < 400)
  161.          {
  162.             if(!_loc1_[_loc2_])
  163.             {
  164.                return;
  165.             }
  166.             _loc2_++;
  167.          }
  168.          API.unlockMedal("A Connoisseur of Fluffy Pillows");
  169.       }
  170.      
  171.       private function _BestiaryMedalCheckBackup() : void
  172.       {
  173.          if(FP.game_world.local_save.game_time >= 4)
  174.          {
  175.             API.unlockMedal("Bully to Toads");
  176.          }
  177.          if(FP.game_world.local_save.game_time >= 10)
  178.          {
  179.             API.unlockMedal("Slayer of Dragons");
  180.          }
  181.          if(FP.saver.CheckGeneralArray(108))
  182.          {
  183.             API.unlockMedal("Breaker of Robots");
  184.          }
  185.          if(FP.game_world.local_save.game_time >= 22)
  186.          {
  187.             API.unlockMedal("Enemy to Kobolds");
  188.          }
  189.       }
  190.      
  191.       public function UnlockBestiaryMedal(param1:int) : void
  192.       {
  193.          switch(param1)
  194.          {
  195.             case 0:
  196.                API.unlockMedal("Never knew what hit him");
  197.                break;
  198.             case 1:
  199.                API.unlockMedal("Harpy Backfire");
  200.                break;
  201.             case 2:
  202.                API.unlockMedal("Bully to Toads");
  203.                break;
  204.             case 3:
  205.                API.unlockMedal("Slayer of Dragons");
  206.                break;
  207.             case 4:
  208.                API.unlockMedal("Breaker of Robots");
  209.                break;
  210.             case 5:
  211.                API.unlockMedal("Enemy to Kobolds");
  212.          }
  213.       }
  214.      
  215.       public function CoinAddCheckMedal(param1:int) : void
  216.       {
  217.          if(this._unlocked_coins_medal)
  218.          {
  219.             return;
  220.          }
  221.          FP.game_world.local_save.coins_collected_total = FP.game_world.local_save.coins_collected_total + param1;
  222.          if(FP.game_world.local_save.coins_collected_total >= 1000)
  223.          {
  224.             API.unlockMedal("Treasure Hunter");
  225.             this._unlocked_coins_medal = true;
  226.          }
  227.       }
  228.      
  229.       public function BoxBreakCheckMedal(param1:int = 1) : void
  230.       {
  231.          if(this._unlock_box_break_medal)
  232.          {
  233.             return;
  234.          }
  235.          FP.game_world.local_save.boxes_broken_count = FP.game_world.local_save.boxes_broken_count + param1;
  236.          if(FP.game_world.local_save.boxes_broken_count >= 100)
  237.          {
  238.             this._unlock_box_break_medal = true;
  239.             API.unlockMedal("Property Destruction");
  240.          }
  241.       }
  242.      
  243.       public function EatFoodCheckMedal(param1:int, param2:Boolean = false) : void
  244.       {
  245.          if(!param2)
  246.          {
  247.             FP.game_world.local_save.good_food_consumed = FP.game_world.local_save.good_food_consumed + 1;
  248.             if(param1 == 21 || param1 == 39 || param1 == 49 || param1 == 58 || param1 == 75)
  249.             {
  250.                FP.game_world.local_save.bad_food_consumed = FP.game_world.local_save.bad_food_consumed + 1;
  251.             }
  252.          }
  253.          if(FP.game_world.local_save.good_food_consumed >= 30)
  254.          {
  255.             API.unlockMedal("Big Eater");
  256.          }
  257.          if(FP.game_world.local_save.bad_food_consumed >= 5)
  258.          {
  259.             API.unlockMedal("Never waste food");
  260.          }
  261.       }
  262.      
  263.       private function _BeatGameBackupCheck() : void
  264.       {
  265.          if(FP.saver.CheckGeneralArray(351))
  266.          {
  267.             API.unlockMedal("The End");
  268.          }
  269.       }
  270.      
  271.       public function BeatGameMedalsCheck() : void
  272.       {
  273.          Sfx.setVolume("m",1);
  274.          Sfx.setVolume(null,1);
  275.          API.unlockMedal("The End");
  276.          var _loc1_:SaveFileX = FP.game_world.local_save;
  277.          var _loc2_:int = _loc1_.accumulated_time_played + 0.001 * (FP.game_world.GetTime() - _loc1_.time_started_playing);
  278.          if(_loc2_ <= 3870)
  279.          {
  280.             if(_loc2_ >= 1200)
  281.             {
  282.                API.unlockMedal("Speed Runner!");
  283.             }
  284.          }
  285.          if(_loc1_.times_died == 0)
  286.          {
  287.             API.unlockMedal("Indomitable!");
  288.          }
  289.       }
  290.      
  291.       public function NGPrint(param1:String) : void
  292.       {
  293.          API.logCustomEvent(param1);
  294.       }
  295.      
  296.       public function DisplayUnlockedMedals() : void
  297.       {
  298.          var _loc4_:String = null;
  299.          var _loc5_:uint = 0;
  300.          var _loc1_:Array = API.medals;
  301.          var _loc2_:uint = 0;
  302.          var _loc3_:uint = 0;
  303.          while(_loc3_ < _loc1_.length)
  304.          {
  305.             _loc4_ = _loc1_[_loc3_].name;
  306.             _loc5_ = _loc1_[_loc3_].value;
  307.             if(_loc1_[_loc3_].unlocked)
  308.             {
  309.                _loc2_ = _loc2_ + _loc5_;
  310.             }
  311.             _loc3_++;
  312.          }
  313.       }
  314.    }
  315. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement