Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------------------------------
- --[[ blockBuster.lua v0.1 by KBM-Quine ]]--
- --[[ name suggested by Enjl. ]]--
- --[[ code help from: ]]--
- --[[ MrDoubleA ]]--
- --[[ with code heavily borrowed from modernReserveItems.lua ]]--
- -------------------------------------------------------------------
- local blockBuster = {}
- local blockManager = require("blockManager")
- local blockutils = require("blocks/blockutils")
- blockBuster.enabled = true
- blockBuster.npcOwnersToBlocks = false
- blockBuster.playSounds = true
- blockBuster.bumpAmount = 12
- -- setup constants for reference throughout code
- COIN_STYLE_MARIO = 1
- COIN_STYLE_TOAD = 2
- COIN_STYLE_OTHER = 3
- COIN_STYLE_CUSTOM = 4
- ITEM_STYLE_DEFAULT = 1
- ITEM_STYLE_CUSTOM = 2
- function blockBuster.randLinkCoins(table)
- if table == nil then return end
- local npcID = table[1]
- if RNG.random() * 20 <= 3 then
- npcID = table[2]
- elseif RNG.random() * 60 <= 3 then
- npcID = table[3]
- end
- return npcID
- end
- local properties = {
- defaults = {transforms = {transformID = 2, centred = false}, coins = {style = COIN_STYLE_MARIO, npc = 10, sound = 14, effect = 11}, items = {style = ITEM_STYLE_DEFAULT, direction = 0, usePlrDir = false, forcedState = 1, forcedState2 = 0, upperForcedState = 3, upperForcedStateState2 = 0, speedX = 0, speedY = 0, upperSpeedX = 0, upperSpeedY = 0, offsetX = 0, offsetY = 0, upperOffsetX = 0, upperOffsetY = 4, ai = {}, upperAI = {}, despawnTimer = 1000}},
- mario = {transforms = {}, coins = {style = COIN_STYLE_MARIO}, items = {progressivePowerups = true}},
- luigi = {transforms = {}, coins = {style = COIN_STYLE_OTHER, coinClusterMax = 21, coinClusterNulls = true}, items = {progressivePowerups = true}},
- peach = {transforms = {}, coins = {style = COIN_STYLE_MARIO}, items = {progressivePowerups = true, mountID = 35}},
- toad = {transforms = {}, coins = {style = COIN_STYLE_TOAD, npc = 138, multiHitAmount = 3}, items = {progressivePowerups = true, mountID = 35}},
- link = {transforms = {}, coins = {style = COIN_STYLE_OTHER, coinClusterMax = 6, coinClusterNulls = true, npc = {251, 252, 253}, sound = 81, coinFunc = blockBuster.randLinkCoins}, items = {mushID = 250, coinID = 251, progressivePowerups = false}},
- }
- local characterProperties = {}
- local propertyPresets = { -- take this table...
- mario = {CHARACTER_MARIO, CHARACTER_WARIO, CHARACTER_UNCLEBROADSWORD},
- luigi = {CHARACTER_LUIGI, CHARACTER_BOWSER, CHARACTER_ZELDA},
- peach = {CHARACTER_PEACH, CHARACTER_NINJABOMBERMAN, CHARACTER_ROSALINA},
- toad = {CHARACTER_TOAD, CHARACTER_MEGAMAN, CHARACTER_KLONOA, CHARACTER_ULTIMATERINKA},
- link = {CHARACTER_LINK, CHARACTER_SNAKE, CHARACTER_SAMUS}
- }
- for k,v in pairs(propertyPresets) do -- and copy the defaults to the appropriate character
- for _,v2 in ipairs(v) do
- characterProperties[v2] = table.join(characterProperties[v2] or {}, properties[k])
- end
- end
- local blockProperties = {
- [55] = {transforms = {transformID = 55}},
- [60] = {transforms = {transformID = 192}, coins = {npc = 88}},
- [88] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [89] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [90] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [159] = {transforms = {transformID = 159}},
- [171] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [174] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [177] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [180] = {transforms = {transformID = 89}, coins = {npc = 33}},
- [188] = {transforms = {transformID = 192}, coins = {npc = 88}},
- [192] = {transforms = {transformID = 192}, coins = {npc = 88}},
- [193] = {transforms = {transformID = 192}, coins = {npc = 88}},
- [224] = {transforms = {transformID = 225}},
- [225] = {transforms = {transformID = 225}},
- [226] = {transforms = {transformID = 225}},
- [369] = {transforms = {transformID = 192}, coins = {npc = 88}},
- }
- sourceNPCTimeOffScreen = mem(0x00B2C85A, FIELD_WORD)
- local itemProperties = {
- [9] = {items = {isMush = true}},
- [10] = {items = {isCoin = true}},
- [14] = {items = {isPowerup = true, mushID = 9}},
- [33] = {items = {isCoin = true}},
- [34] = {items = {forcedState = 0, speedY = -6, ai = {ai1 = 0}, offsetY = -32, isPowerup = true, mushID = 9}},
- [88] = {items = {isCoin = true}},
- [96] = {items = {forcedState = 0, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [98] = {items = {forcedState = 0, frame = 1, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [99] = {items = {forcedState = 0, frame = 2, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [100] = {items = {forcedState = 0, frame = 3, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [138] = {items = {isCoin = true}},
- [148] = {items = {forcedState = 0, frame = 4, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [149] = {items = {forcedState = 0, frame = 5, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [150] = {items = {forcedState = 0, frame = 6, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [182] = {items = {isPowerup = true, mushID = 184}},
- [183] = {items = {isPowerup = true, mushID = 185}},
- [184] = {items = {isMush = true}},
- [185] = {items = {isMush = true}},
- [228] = {items = {forcedState = 0, frame = 7, despawnTimer = sourceNPCTimeOffScreen*20, offsetY = -32, isEgg = true}},
- [249] = {items = {isMush = true}},
- [258] = {items = {isCoin = true, altID = 252}},
- [264] = {items = {isPowerup = true, mushID = 9}},
- [277] = {items = {isPowerup = true, mushID = 185}},
- }
- local BlocksToProcess = {}
- function blockBuster.onInitAPI()
- registerEvent(blockBuster, "onPostBlockHit", false)
- registerEvent(blockBuster, "onTickEnd", false)
- registerCustomEvent(blockBuster, "onCustomCoinEvent")
- registerCustomEvent(blockBuster, "onCustomItemEvent")
- end
- -- not very user friendly to new coders, but might uncomment? don't know (old, may not work now)
- -- function blockBuster.getProperties(args)
- -- return args.type[args.table or args.ID]
- -- end
- -- function blockBuster.setProperties(args)
- -- local pTable = args.type
- -- pTable[args.ID] = table.join(pTable[args.ID] or {}, args.properties)
- -- for k,_ in pairs(args.properties) do
- -- if not (pTable[args.ID][k] == args.properties[k]) then
- -- pTable[args.ID][k] = args.properties[k]
- -- end
- -- end
- -- end
- function blockBuster.getItemProperties(npcID)
- return itemProperties[npcID]
- end
- function blockBuster.getBlockProperties(blockID)
- return blockProperties[blockID]
- end
- function blockBuster.getCharaterProperties(characterID)
- return characterProperties[characterID]
- end
- function blockBuster.setItemProperties(npcID, properties)
- itemProperties[npcID] = table.join(itemProperties[npcID] or {}, properties) -- so ids without default tables work
- for k,_ in pairs(properties) do -- then merge any that DO have default tables
- itemProperties[npcID][k] = table.join(itemProperties[npcID][k] or {}, properties[k])
- for k2,_ in pairs(properties[k]) do
- itemProperties[npcID][k][k2] = properties[k][k2]
- end
- end
- end
- function blockBuster.setBlockProperties(blockID, properties)
- blockProperties[blockID] = table.join(blockProperties[blockID] or {}, properties)
- for k,_ in pairs(properties) do
- blockProperties[blockID][k] = table.join(blockProperties[blockID][k] or {}, properties[k])
- for k2,_ in pairs(properties[k]) do
- blockProperties[blockID][k][k2] = properties[k][k2]
- end
- end
- end
- function blockBuster.setCharacterProperties(characterID, properties)
- characterProperties[characterID] = table.join(characterProperties[characterID] or {}, properties)
- for k,_ in pairs(properties) do
- characterProperties[characterID][k] = table.join(characterProperties[characterID][k] or {}, properties[k])
- for k2,_ in pairs(properties[k]) do
- characterProperties[characterID][k][k2] = properties[k][k2]
- end
- end
- end
- function blockBuster.decrementCoinContents(block)
- block.data.BBTable.oldContents = block.data.BBTable.oldContents - 1
- end
- function blockBuster.transformBlock(block, transformID, centred)
- if block.data.BBTable.oldContents <= 0 then
- block:transform(transformID, centred)
- end
- end
- -- iBlocks (or interesting blocks/blocks of interest according to comments), blocks that are doing something interesting. messing with this so bumps hurt npcs. given to me by MDA
- local IBLOCK_COUNT = 0x00B25784 -- iBlocks in source. holds the total amount of iBlocks
- local IBLOCK_ADDR = mem(0x00B25798,FIELD_DWORD) -- iBlock in source. the array of iBlocks
- local function setasIBlock(block) -- sets a block as an iBlock, basic stuff
- mem(IBLOCK_COUNT,FIELD_WORD, mem(IBLOCK_COUNT,FIELD_WORD) + 1)
- mem(IBLOCK_ADDR + mem(IBLOCK_COUNT,FIELD_WORD)*2,FIELD_WORD, block.idx)
- end
- local function sourceShakeUp(block) -- clone of sources' BlockShakeUp https://github.com/smbx/smbx-legacy-source/blob/master/modBlocks.bas#L823
- if not block.isHidden then
- block:mem(0x52, FIELD_WORD, -blockBuster.bumpAmount)
- block:mem(0x54, FIELD_WORD, blockBuster.bumpAmount)
- block:mem(0x56, FIELD_WORD, 0)
- end
- if not (block.idx == mem(IBLOCK_ADDR + mem(IBLOCK_COUNT,FIELD_WORD)*2,FIELD_WORD)) then
- setasIBlock(block)
- end
- end
- local function sourceShakeDown(block) -- ditto for BlockShakeDown https://github.com/smbx/smbx-legacy-source/blob/master/modBlocks.bas#L851
- if not block.isHidden then
- block:mem(0x52, FIELD_WORD, blockBuster.bumpAmount)
- block:mem(0x54, FIELD_WORD, -blockBuster.bumpAmount)
- block:mem(0x56, FIELD_WORD, 0)
- end
- if not (block.idx == mem(IBLOCK_ADDR + mem(IBLOCK_COUNT,FIELD_WORD)*2,FIELD_WORD)) then
- setasIBlock(block)
- end
- end
- function blockBuster.resolveBumps(block, upper)
- if not upper then
- sourceShakeUp(block)
- else
- sourceShakeDown(block)
- end
- end
- function blockBuster.resolveProperties(id, pl, type, table, field)
- local key
- local pTable = type
- if (pTable[id] ~= nil and pTable[id][table] ~= nil and pTable[id][table][field] ~= nil) then
- key = pTable[id][table][field]
- else
- key = properties.defaults[table][field]
- end
- if (pl ~= nil and characterProperties[pl.character] ~= nil and characterProperties[pl.character][table] ~= nil and characterProperties[pl.character][table][field] ~= nil)then
- key = characterProperties[pl.character][table][field]
- end
- return key
- end
- function blockBuster.defaultCoinAction(block, soundID, transformID, centred, effectID)
- Misc.coins(1,false)
- if blockBuster.playSounds then
- SFX.play(soundID or properties.defaults.coins.sound)
- end
- if not (effectID == nil or effectID == 0) then
- Effect.spawn(effectID, block.x + block.width*0.5, block.y)
- end
- blockBuster.decrementCoinContents(block)
- blockBuster.transformBlock(block, transformID, centred)
- end
- function blockBuster.doMultiSetup(block, pl) -- setup blocks to be RapidHit (name from source), toad style. may allow items to use this, not sure yet
- local multihit = blockBuster.resolveProperties(block.id, pl, blockProperties, "coins", "multiHitAmount")
- block.data.BBTable.oldMulti = math.floor(RNG.random() * multihit) + 1
- block.data.BBTable.isMulti = true
- block.data.BBTable.player = pl
- block:mem(0x04, FIELD_WORD, block.data.BBTable.oldMulti)
- end
- function blockBuster.checkCollisionUp(block) -- based on https://github.com/smbx/smbx-legacy-source/blob/master/modBlocks.bas#L194
- for _,v in ipairs(Block.getIntersecting(block.x + 1, block.y - 31, (block.x + 1) + 30, (block.y - 31) + 30)) do
- if v and not (v == block) and not Block.config[v.id].semisolid and not v.isHidden and not Block.config[v.id].sizable then
- return true
- end
- end
- end
- function blockBuster.checkCollisionDown(block) -- vaugely based on https://github.com/smbx/smbx-legacy-source/blob/master/modBlocks.bas#L79
- for _,v in ipairs(Block.getIntersecting(block.x, block.y + block.height, block.x + block.width, (block.y + block.height) + 17)) do
- if v and not (v == block) then
- return true
- end
- end
- end
- function blockBuster.spawnCoin(block, upper, pl, npcID)
- local spawnLayer = blockBuster.resolveProperties(block.id, pl, blockProperties, "coins", "spawnLayer")
- local s = NPC.spawn(npcID, block.x + (block.width*0.5) - (NPC.config[npcID].width*0.5), block.y-NPC.config[npcID].height - 0.01, blockutils.getBlockSection(block), false, false)
- if spawnLayer then
- s.layerName = spawnLayer
- end
- s.ai1 = 1
- s.speedX = RNG.random() * 3 - 1.5
- s.speedY = -RNG.random() * 4 - 3
- if upper then
- s.speedY = -s.speedY * 0.5
- s.y = block.y+block.height
- end
- s:mem(0x156, FIELD_WORD, 20) -- timer to make npcs immune to harm. makes it so iBlocks don't collect them instantly
- end
- function blockBuster.filterPowerups(npcID, pl) -- https://github.com/smbx/smbx-legacy-source/blob/master/modBlocks.bas#L345
- local mushID = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "mushID")
- local isPowerup = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "isPowerup")
- local progressivePowerups = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "progressivePowerups")
- local mushroom = false
- if pl and pl.powerup == PLAYER_SMALL and not mem(0x00B2D740, FIELD_BOOL) and progressivePowerups then mushroom = true end --battle mode address
- if (isPowerup and mushID and mushroom) then
- npcID = mushID
- end
- return npcID
- end
- function blockBuster.filterCharacterItems(npcID, ai1, pl) -- https://github.com/smbx/smbx-legacy-source/blob/master/modNPC.bas#L12271
- local mushID = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "mushID")
- local isMush = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "isMush")
- local isEgg = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "isEgg")
- local mountID = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "mountID")
- local isCoin = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "isCoin")
- local coinID = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "coinID")
- local altID = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "altID")
- if isMush then
- if mushID then
- npcID = mushID
- end
- end
- if isEgg then
- local eggContains = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "isEgg")
- local altMountID = blockBuster.resolveProperties(ai1, pl, itemProperties, "items", "altID")
- if eggContains then
- if mountID then
- if altMountID then
- ai1 = altMountID
- end
- end
- end
- end
- if isCoin then
- if coinID then
- npcID = coinID
- if altID then
- npcID = altID
- end
- end
- end
- return npcID, ai1
- end
- function blockBuster.spawnItem(block, upper, pl, npcID) -- this looks familiar lol
- local forced = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "forcedState")
- local forced2 = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "forcedState2")
- local direction = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "direction")
- local usePlrDir = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "usePlrDir")
- local speedX = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "speedX")
- local speedY = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "speedY")
- local offsetX = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "offsetX")
- local offsetY = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "offsetY")
- local ai = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "ai")
- local data = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "data")
- local despawnTimer = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "despawnTimer")
- local isEgg = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "isEgg")
- local frame = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "frame")
- local immunity = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "immunity")
- local upperOffsetX = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperOffsetX")
- local upperOffsetY = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperOffsetY")
- local upperSpeedX = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperSpeedX")
- local upperSpeedY = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperSpeedY")
- local upperAI = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperAI")
- local upperForced = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperForcedState")
- local upperForced2 = blockBuster.resolveProperties(npcID, pl, itemProperties, "items", "upperForcedState2")
- local tempWidth = block.width
- local tempX = block.x
- if tempWidth == 32 then
- tempWidth = block.width - 0.1
- tempX = block.x - 0.05
- end
- if upper then
- offsetX = upperOffsetX
- offsetY = upperOffsetY
- speedX = upperSpeedX
- speedY = upperSpeedY
- ai = upperAI
- forced = upperForced
- forced2 = upperForcedState2
- end
- if isEgg then
- ai.ai1 = npcID
- npcID = 96
- end
- npcID = blockBuster.filterPowerups(npcID, pl)
- npcID, ai.ai1 = blockBuster.filterCharacterItems(npcID, ai.ai1, pl)
- local s = NPC.spawn(npcID, tempX + (tempWidth*0.5) - (NPC.config[npcID].width*0.5) + offsetX, block.y + offsetY, blockutils.getBlockSection(block), false, false)
- if spawnLayer then
- s.layerName = spawnLayer
- end
- if frame then
- s.animationFrame = frame
- end
- if data ~= nil then
- for k,_ in pairs(data) do
- if not (s.data[k] == data[k]) then
- s.data[k] = data[k]
- end
- end
- end
- if ai ~= nil then
- for k,_ in pairs(ai) do
- if not (s[k] == ai[k]) then
- s[k] = ai[k]
- end
- end
- end
- s:mem(0x124, FIELD_BOOL, true) -- active flag
- if despawnTimer then
- s.despawnTimer = despawnTimer
- end
- if direction and usePlrDir ~= nil and not usePlrDir then
- s.direction = direction
- elseif usePlrDir ~= nil and usePlrDir then
- s.direction = pl.direction
- end
- if forced then
- s:mem(0x138, FIELD_WORD, forced) -- forced state/effect
- end
- if forced2 then
- s:mem(0x13C, FIELD_DFLOAT, forced2) -- a forced state timer/effect2
- end
- s.speedY = speedY
- s.speedX = speedX
- if forced == 1 then
- s.height = 0
- end
- if immunity then
- s:mem(0x156, FIELD_WORD, immunity) -- immune timer
- end
- return s
- end
- function blockBuster.onPostBlockHit(v, upper, pl)
- if not blockBuster.enabled then return end
- if v:mem(0x52, FIELD_WORD) ~= 0 or v:mem(0x54, FIELD_WORD) ~= 0 or v:mem(0x56, FIELD_WORD) ~= 0 then return end -- "if the block has just been hit, ignore" comment from source https://github.com/smbx/smbx-legacy-source/blob/master/modBlocks.bas#L68
- v.data.BBTable = v.data.BBTable or {}
- local data = v.data.BBTable
- if not (v.contentID == 0) then -- void blocks contents to overwrite how things are done if the block isn't empty
- v:mem(0x5A , FIELD_BOOL, false) -- allow invisible blocks to work properly with blockBuster
- data.oldContents = v.contentID
- data.oldMulti = v:mem(0x04, FIELD_WORD)
- v.contentID = 0
- v:mem(0x04, FIELD_WORD, 0)
- table.insert(BlocksToProcess, v.idx)
- end
- if pl == nil then
- if data.player and not (pl == data.player) then -- should make RapidHit work with character configs
- pl = data.player
- end
- if blockBuster.npcOwnersToBlocks then -- allow transferring this system from thrown npcs
- for _,n in ipairs(NPC.getIntersecting(v.x-1,v.y-1,v.x+v.width+1,v.y+v.height+1)) do
- if n:mem(0x132,FIELD_WORD) > 0 and n:mem(0x136,FIELD_BOOL) and pl == nil then
- pl = Player.get()[n:mem(0x132,FIELD_WORD)]
- end
- end
- end
- end
- if upper and data.oldContents then
- upper = not blockBuster.checkCollisionDown(v)
- end
- if data.oldContents and data.oldContents > 0 and data.oldContents < 100 then -- coin handling
- local coinStyle = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "style")
- local multiHitTimes = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "multiHitAmount")
- local npcSpawnID = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "npc")
- local coinSoundID = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "sound")
- local blockTransformID = blockBuster.resolveProperties(v.id, pl, blockProperties, "transforms", "transformID")
- local centred = blockBuster.resolveProperties(v.id, pl, blockProperties, "transforms", "centred")
- local effectID = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "effect")
- local coinFunction = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "coinFunc")
- if not (multiHitTimes == nil) and multiHitTimes > 0 then
- if v:mem(0x04, FIELD_WORD) == 0 and not data.isMulti then
- blockBuster.doMultiSetup(v, pl)
- else
- data.oldMulti = data.oldMulti - 1
- end
- elseif not multiHitTimes and not data.isMulti then
- v:mem(0x04, FIELD_WORD, 0) -- pervent vanilla multihitting
- end
- if coinStyle == COIN_STYLE_MARIO then
- blockBuster.defaultCoinAction(v, coinSoundID, blockTransformID, centred, effectID)
- blockBuster.resolveBumps(v, upper)
- elseif coinStyle == COIN_STYLE_TOAD then
- if not blockBuster.checkCollisionUp(v) then
- blockBuster.spawnCoin(v, upper, pl, npcSpawnID)
- if blockBuster.playSounds then
- SFX.play(coinSoundID)
- end
- blockBuster.decrementCoinContents(v)
- blockBuster.transformBlock(v, blockTransformID, centred)
- else
- blockBuster.defaultCoinAction(v, coinSoundID, blockTransformID, centred, effectID)
- end
- blockBuster.resolveBumps(v, upper)
- elseif coinStyle == COIN_STYLE_OTHER then
- if not blockBuster.checkCollisionUp(v) then
- local max = 0
- if data.oldContents < characterProperties[pl.character].coins.coinClusterMax then
- max = data.oldContents
- else
- max = characterProperties[pl.character].coins.coinClusterMax
- end
- for i=1, max do
- local tempCoinID = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "npc")
- if coinFunction then
- tempCoinID = coinFunction(tempCoinID)
- end
- blockBuster.spawnCoin(v, upper, pl, tempCoinID)
- if not characterProperties[pl.character].coins.coinClusterNulls then
- blockBuster.decrementCoinContents(v)
- end
- end
- if blockBuster.playSounds then
- SFX.play(coinSoundID)
- end
- if characterProperties[pl.character].coins.coinClusterNulls then
- data.oldContents = 0
- end
- blockBuster.transformBlock(v, blockTransformID, centred)
- else
- blockBuster.defaultCoinAction(v, nil, blockTransformID, centred, effectID)
- end
- blockBuster.resolveBumps(v, upper)
- elseif coinStyle == COIN_STYLE_CUSTOM then
- local coinStyle = blockBuster.resolveProperties(v.id, pl, blockProperties, "coins", "style")
- -- allow making one's own coin code
- EventManager.callEvent("onCustomCoinEvent", v, upper, pl, data.oldContents)
- end
- end
- if data.oldContents and data.oldContents >= 1000 then -- npc handling
- local itemStyle = blockBuster.resolveProperties(v.id, pl, blockProperties, "items", "style")
- if itemStyle == ITEM_STYLE_DEFAULT then
- local npcSpawnID = data.oldContents - 1000
- blockBuster.spawnItem(v, upper, pl, npcSpawnID)
- data.oldContents = 0
- if blockBuster.playSounds then
- SFX.play(7)
- end
- blockBuster.transformBlock(v, blockBuster.resolveProperties(v.id, pl, blockProperties, "transforms", "transformID"), blockBuster.resolveProperties(v.id, pl, blockProperties, "transforms", "centred"))
- blockBuster.resolveBumps(v, upper)
- elseif itemStyle == ITEM_STYLE_CUSTOM then
- -- allow making one's own item code
- EventManager.callEvent("onCustomItemEvent", v, upper, pl, data.oldContents)
- end
- end
- end
- function blockBuster.onTickEnd()
- if not blockBuster.enabled and #BlocksToProcess == 0 then return end
- for k,v in ipairs(BlocksToProcess) do
- local block = Block(v)
- local data = block.data.BBTable
- block.contentID = data.oldContents -- restore old contents so coins work
- data.oldContents = nil
- block:mem(0x04, FIELD_WORD, data.oldMulti)
- data.oldMulti = nil
- if block:mem(0x04, FIELD_WORD) <= 0 then -- only get rid of other feilds if not using them for multihitting
- data.player = nil
- data.isMulti = nil
- block:mem(0x04, FIELD_WORD, 0)
- end
- table.remove(BlocksToProcess, k)
- end
- end
- blockBuster.properties = properties
- return blockBuster
Add Comment
Please, Sign In to add comment