Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------
- -- BONUS SCRIPT --
- -- by Natsu --
- -- v0.1.0 --
- ---------------------------------------------------
- local bonus = {}
- ----------------------------------------------------------------------------
- -- VARIABLES --
- ----------------------------------------------------------------------------
- local sectionNumber = 0 --Section where the bonus is located
- local doHandling = false --Controls whether the bonus controls apply or not
- ----------------------------------------------------------------------------
- -- API-related Sound Effects --
- ----------------------------------------------------------------------------
- local bonusDeathSFX = Audio.SfxOpen(Misc.resolveFile("bonusLose.ogg")) --Loads bonusLose SFX
- local bonusWinSFX = Audio.SfxOpen(Misc.resolveFile("bonusWin.ogg")) --Loads bonusWin SFX
- ----------------------------------------------------------------------------
- function bonus.onInitAPI()
- registerEvent(bonus, "onLoadSection", "sectionLoad")
- registerEvent(bonus, "onTick", "handling")
- registerEvent(bonus, "onNPCKill", "itemGet")
- end
- --This function takes the parameters sent from the luna.lua file
- function bonus.parameters(bonusSection)
- sectionNumber = bonusSection
- end
- --This function replaces the death SFX if the player is in the bonus section and switches
- --doHandling to true
- function bonus.sectionLoad()
- if player.section == sectionNumber then
- Audio.sounds[8].sfx = bonusDeathSFX
- doHandling = true
- end
- end
- --This function prevents player death and pauses the game
- function bonus.handling()
- if player:mem(0x13E, FIELD_WORD) > 0 and doHandling then
- player:mem(0x13E, FIELD_WORD, 0)
- Misc.pause()
- Animation.spawn(75, player.x, player.y)
- end
- end
- --This function plays the bonus win fanfare
- function bonus.itemGet(eventObj, npcID, killReason)
- if npcID.id == 178 then
- Audio.MusicStop()
- SFX.play("bonusWinSFX")
- end
- end
- return bonus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement