Advertisement
KBM-Quine

anotherPowerDownLibrary.lua pre-release 1

Feb 6th, 2021
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. local anotherPowerDownLibrary = {}
  2. local pm = require("playermanager")
  3.  
  4. anotherPowerDownLibrary.enabled = true
  5. anotherPowerDownLibrary.customForcedState = 751
  6.  
  7. function anotherPowerDownLibrary.onInitAPI()
  8.     registerEvent(anotherPowerDownLibrary, "onTick", "onTick", true)
  9. end
  10.  
  11. local playerData = {}
  12.  
  13. function anotherPowerDownLibrary.onTick()
  14.     if not isOverworld and anotherPowerDownLibrary.enabled then
  15.         for _, p in ipairs(Player.get()) do
  16.             local ps = PlayerSettings.get(pm.getCharacters()[p.character].base, p.CurrentPowerup)
  17.             playerData[p] = playerData[p] or {}
  18.             playerData[p].curState = playerData[p].curState or 0
  19.  
  20.             if p.forcedTimer == 0 then --if not in a forcedState, track player powerup
  21.                 playerData[p].curState = p.CurrentPowerup
  22.             end
  23.             if p.forcedState == 2 then --if powering down, change it the custom state
  24.                 if playerData[p].curState == 2 then return end --cancel if the player is big
  25.                 p.forcedState = anotherPowerDownLibrary.customForcedState
  26.             end
  27.             if p.forcedState == anotherPowerDownLibrary.customForcedState then --taken from modPlayer.bas, line 7477
  28.                 if p:mem(0x12E, FIELD_BOOL) == true then --ducking state, seemingly wouldn't work if using player.InDuckingPosition?
  29.                     p:mem(0x132, FIELD_BOOL, true) --standing value?? seems to corrilates to .stand in modPlayer.bas, is player.Unknown132
  30.                     p:mem(0x12E, FIELD_BOOL, false) --ducking state
  31.                     p.height = ps.hitboxDuckHeight
  32.                     p.y = p.y - ps.hitboxHeight + ps.hitboxDuckHeight
  33.                 end
  34.                 p.forcedTimer = p.forcedTimer + 1
  35.                 p.CurrentPlayerSprite = 1
  36.                 if p.forcedTimer % 5 == 0 then
  37.                     if p.CurrentPowerup == 2 then
  38.                         p.CurrentPowerup = playerData[p].curState
  39.                     else
  40.                         p.CurrentPowerup = 2
  41.                     end
  42.                 end
  43.                 if p.forcedTimer >= 50 then
  44.                     if p.CurrentPowerup == playerData[p].curState then
  45.                         p.CurrentPowerup = 2
  46.                     end
  47.                     p.BlinkTimer = 150
  48.                     p.BlinkState = true
  49.                     p.forcedState = 0
  50.                     p.forcedTimer = 0
  51.                 end
  52.             end
  53.         end
  54.     end
  55. end
  56.  
  57. return anotherPowerDownLibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement