Advertisement
KBM-Quine

anotherPowerDownLibrary.lua pre-release 2

Feb 6th, 2021
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.71 KB | None | 0 0
  1. local anotherPowerDownLibrary = {}
  2. local pm = require("playermanager")
  3. local bowser = require("characters/bowser")
  4.  
  5. anotherPowerDownLibrary.enabled = true
  6. anotherPowerDownLibrary.customForcedState = 751
  7. anotherPowerDownLibrary.nonUsableCharacters = { --these characters either don't work with it or have unique enough gameplay that warrants non-inclusion
  8.     CHARACTER_PEACH,
  9.     CHARACTER_TOAD,
  10.     CHARACTER_LINK,
  11.     CHARACTER_MEGAMAN,
  12.     CHARACTER_KLONOA,
  13.     CHARACTER_NINJABOMBERMAN,
  14.     CHARACTER_ROSALINA,
  15.     CHARACTER_SNAKE,
  16.     CHARACTER_ULTIMATERINKA,
  17.     CHARACTER_SAMUS
  18. }
  19.  
  20. function anotherPowerDownLibrary.onInitAPI()
  21.     registerEvent(anotherPowerDownLibrary, "onTick", "onTick", true)
  22. end
  23.  
  24. local playerData = {}
  25.  
  26. function anotherPowerDownLibrary.onTick()
  27.     if not isOverworld and anotherPowerDownLibrary.enabled then
  28.         for _, p in ipairs(Player.get()) do
  29.             local ps = PlayerSettings.get(pm.getCharacters()[p.character].base, p.powerup)
  30.             playerData[p] = playerData[p] or {}
  31.             playerData[p].curState = playerData[p].curState or 0
  32.  
  33.             for _,v in ipairs(anotherPowerDownLibrary.nonUsableCharacters) do --stops any characters in this list from using this system
  34.                 if p.character == v then
  35.                     return
  36.                 end
  37.             end
  38.  
  39.             if p.BlinkTimer == 120 and p.character == CHARACTER_UNCLEBROADSWORD and playerData[p].curState ~= 2 then
  40.                 p.powerup = 2
  41.                 return
  42.             end
  43.             if p.BlinkTimer > 0 and p.character == CHARACTER_BOWSER then
  44.                 if playerData[p].curState > 2 then
  45.                     bowser.setHP(2)
  46.                 end
  47.                 return
  48.             end
  49.             if p.forcedTimer == 0 then --if a forcedState timer isn't active, track player powerup
  50.                 playerData[p].curState = p.powerup
  51.             end
  52.             if p.forcedState == 2 then --if powering down, change it the custom state
  53.                 if playerData[p].curState == 2 then return end --cancel if the player is big
  54.                 if p.character == CHARACTER_BOWSER then return end --cancel if the player is big
  55.                 p.forcedState = anotherPowerDownLibrary.customForcedState
  56.             end
  57.             if p.forcedState == anotherPowerDownLibrary.customForcedState then --taken from modPlayer.bas, line 7477
  58.                 if p:mem(0x12E, FIELD_BOOL) == true then --ducking state, seemingly wouldn't work if using player.InDuckingPosition?
  59.                     p:mem(0x132, FIELD_BOOL, true) --standing value?? seems to corrilates to .stand in modPlayer.bas, is player.Unknown132
  60.                     p:mem(0x12E, FIELD_BOOL, false) --ducking state
  61.                     p.height = ps.hitboxDuckHeight
  62.                     p.y = p.y - ps.hitboxHeight + ps.hitboxDuckHeight
  63.                 end
  64.                 p.forcedTimer = p.forcedTimer + 1
  65.                 -- if p.character ~= CHARACTER_BOWSER then
  66.                 --     p.CurrentPlayerSprite = 1
  67.                 -- end
  68.                 if p.forcedTimer % 5 == 0 then
  69.                     if p.powerup == 2 then
  70.                         p.powerup = playerData[p].curState
  71.                     else
  72.                         p.powerup = 2
  73.                     end
  74.                 end
  75.                 if p.forcedTimer >= 50 then
  76.                     if p.powerup == playerData[p].curState then
  77.                         p.powerup = 2
  78.                     end
  79.                     p.BlinkTimer = 150
  80.                     p.BlinkState = true
  81.                     p.forcedState = 0
  82.                     p.forcedTimer = 0
  83.                 end
  84.             end
  85.         end
  86.     end
  87. end
  88.  
  89. return anotherPowerDownLibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement