Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. --called once when the script loads
  2. function OnInit()
  3.     Bombernauts.SetPowerupSpawnRate(99999, 99999); --disable item spawning
  4. end
  5.  
  6. --called when the game resets and when a player joins
  7. function OnLoadout(player)
  8.     player.SetBombAmmo(0); --disable bomb throwing
  9. end
  10.  
  11. --called 60 times a second
  12. function OnUpdate()
  13.     for player in Bombernauts.GetPlayers() do
  14.         if player.BombAmmo == 0 then
  15.             player.SetBombAmmo(-100); --set bomb ammo to -100 so this condition doesn't retrigger next frame
  16.             Util.Timer("GrantPowers", 4.0, player); --call GrantPowers in 4 seconds
  17.         end
  18.     end
  19. end
  20.  
  21. function GrantPowers(player)
  22.     player.SetBombAmmo(1); --grant a bomb ammo to go along with this stack
  23.    
  24.     --choose 3 *unique* powerups, no conflicting elementals
  25.     power1 = Bombernauts.RandomBombPowerup();
  26.     power2 = Bombernauts.RandomBombPowerup();
  27.     power3 = Bombernauts.RandomBombPowerup();
  28.    
  29.     while powersEqual(power1, power2) do
  30.         power2 = Bombernauts.RandomBombPowerup();
  31.     end
  32.    
  33.     while powersEqual(power1, power3) or powersEqual(power2, power3) do
  34.         power3 = Bombernauts.RandomBombPowerup();
  35.     end
  36.    
  37.     player.GrantPowerup(power1);
  38.     player.GrantPowerup(power2);
  39.     player.GrantPowerup(power3);
  40. end
  41.  
  42. function powersEqual(p1, p2)
  43.     --convert "Elemental_Ice", "Elemental_Fire", etc all to just "Elemental" for comparison
  44.     if string.find(p1, "Elemental") then
  45.         p1 = "Elemental";
  46.     end
  47.     if string.find(p2, "Elemental") then
  48.         p2 = "Elemental";
  49.     end
  50.    
  51.     return p1 == p2;
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement