Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("betterdarkbum", 1)
- local game = Game()
- local HeartCount = 0 -- counts the hearts Dark Bum steals
- local DarkBum = {
- Alt = false, -- allows the player to switch between the two steal animaions
- INIT = true, -- prevent Super Bum functionality
- SPAWNED = false, -- checks if Dark Bum can spawn something
- PAYOUT = nil, -- checks if Dark Bum should spawn something
- BUM = nil -- registers Dark Bum
- }
- local steal = "AltSteal"
- function Mod:onInit(player)
- local player = Isaac.GetPlayer(0)
- if game:GetFrameCount() == 1 then
- -- spawn in if you want
- -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DARK_BUM, Vector(250, 250), Vector(0,0), player) -- testing
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onInit)
- -- let the player set the animation with the debug conosle
- function Mod:setAnimation(consol,para)
- if consol == "setanimation" then
- if DarkBum.Alt == false then
- DarkBum.Alt = true
- steal = "AltSteal"
- Isaac.ConsoleOutput("animation updated. Use alt animation")
- else
- DarkBum.Alt = false
- steal = "Steal"
- Isaac.ConsoleOutput("animation updated. Use default animation")
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.setAnimation)
- function Mod:onNewEvent(player)
- local entities = Isaac.GetRoomEntities()
- local entity = DarkBum.BUM
- -- makes sure that the code doesn't work for Super Bum
- if player:GetPlayerType() == PlayerType.PLAYER_KEEPER
- and player:HasCollectible(CollectibleType.COLLECTIBLE_DARK_BUM)
- and player:HasCollectible(CollectibleType.COLLECTIBLE_KEY_BUM)
- and player:HasCollectible(CollectibleType.COLLECTIBLE_BUM_FRIEND) then
- DarkBum.INIT = false
- end
- -- Dark Bum functionality. He steals Keeper's red hearts
- if player:GetPlayerType() == PlayerType.PLAYER_KEEPER
- and player:HasCollectible(CollectibleType.COLLECTIBLE_DARK_BUM)
- and DarkBum.INIT == true then
- for o = 1, #entities do
- local bum = entities[o]
- if bum.Type == EntityType.ENTITY_FAMILIAR then
- if bum.Variant == FamiliarVariant.DARK_BUM then
- entity = bum
- end
- end
- end
- local Sprite = entity:GetSprite()
- -- we are looking for red hearts
- for m = 1, #entities do -- we go through every entity in the room
- local toSteal = entities[m] -- toSteal are the pickups we want to steal from the Keeper
- if toSteal.Type == EntityType.ENTITY_PICKUP
- and toSteal.Variant == PickupVariant.PICKUP_HEART then
- -- we are looking for all kinds of red hearts
- if toSteal.SubType == HeartSubType.HEART_HALF -- first half red hearts
- and not toSteal:ToPickup():IsShopItem() then
- toSteal:Remove()
- Sprite:Play(steal, true) -- Play costume animation
- if Sprite:IsPlaying(steal) then
- HeartCount = HeartCount + 1 -- half a heart increases the counter by 1
- Mod:SaveData(HeartCount)
- if HeartCount >= 5 then -- pays out at 2,5 hearts
- DarkBum.PAYOUT = true
- end
- end
- end
- if toSteal.SubType == HeartSubType.HEART_FULL -- normal red hearts
- and not toSteal:ToPickup():IsShopItem() then
- toSteal:Remove()
- Sprite:Play(steal, true) -- Play costume animation
- if Sprite:IsPlaying(steal) then
- HeartCount = HeartCount + 2 -- a full heart increases the counter by 2
- Mod:SaveData(HeartCount)
- if HeartCount >= 5 then -- pays out at 2,5 hearts
- DarkBum.PAYOUT = true
- end
- end
- end
- if toSteal.SubType == HeartSubType.HEART_SCARED -- scared red hearts
- and not toSteal:ToPickup():IsShopItem() then
- toSteal:Remove()
- Sprite:Play(steal, true) -- Play costume animation
- if Sprite:IsPlaying(steal) then
- HeartCount = HeartCount + 2 -- a sacred heart increases the counter by 2
- Mod:SaveData(HeartCount)
- if HeartCount >= 5 then -- pays out at 2,5 hearts
- DarkBum.PAYOUT = true
- end
- end
- end
- if toSteal.SubType == HeartSubType.HEART_DOUBLEPACK -- double red hearts
- and not toSteal:ToPickup():IsShopItem() then
- toSteal:Remove()
- Sprite:Play(steal, true) -- Play costume animation
- if Sprite:IsPlaying(steal) then
- HeartCount = HeartCount + 4 -- a double red heart increases the counter by 4
- Mod:SaveData(HeartCount)
- if HeartCount >= 5 then -- pays out at 2,5 hearts
- DarkBum.PAYOUT = true
- end
- end
- end
- end
- end
- if entity.Position:Distance(player.Position) <= 95 then -- distance from the player
- if DarkBum.SPAWNED == false
- and DarkBum.PAYOUT == true then -- 95
- DarkBum.SPAWNED = true
- Sprite:Play("PreCoin", true)
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onNewEvent)
- function Mod:onPickup(DaBum)
- local player = Isaac.GetPlayer(0)
- local entities = Isaac.GetRoomEntities() -- all entities in the room
- local entity = DaBum
- local Sprite = entity:GetSprite()
- local rng = player:GetCollectibleRNG(278) -- 278 = Dark Bum
- local numCoins = (rng:RandomInt(2)) + 2 -- number of coins Dark Bum spawns if you play as the Keeper
- if player:HasCollectible(CollectibleType.COLLECTIBLE_DARK_BUM) then
- -- if you play as the Lost
- if player:GetPlayerType() == PlayerType.PLAYER_THELOST then
- if Sprite:IsPlaying("Spawn") then
- if Sprite:GetFrame() == 1 then
- for j = 1, #entities do
- local entitis = entities[j]
- if entitis.Type == EntityType.ENTITY_PICKUP
- and entitis.Variant == PickupVariant.PICKUP_HEART
- and entitis.SubType == HeartSubType.HEART_SOUL then
- if entitis.SpawnerType == EntityType.ENTITY_FAMILIAR
- and entitis.SpawnerVariant == FamiliarVariant.DARK_BUM then
- entitis:Remove()
- local numBlueSpider = 2 -- number of spiders Dark Bum will spawn
- for k = 1, numBlueSpider do
- player:ThrowBlueSpider(entity.Position, player.Position)
- end
- end
- end
- end
- end
- end
- end
- -- if you play as the Keeper
- if Sprite:IsFinished("PreCoin") then
- HeartCount = HeartCount - 5
- Mod:SaveData(HeartCount)
- Sprite:Play("SpawnCoin", true)
- for i = 1, numCoins do
- angle = math.random(math.floor(360/numCoins)) -- get the angle
- angleVector = Vector.FromAngle(angle + (i-1)*(math.floor(360/numCoins))) -- this distributes the coins equally around Dark Bum
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COIN, CoinSubType.COIN_PENNY, entity.Position, angleVector, entity)
- end
- end
- if Sprite:IsFinished("SpawnCoin") then
- if HeartCount < 5 then
- DarkBum.PAYOUT = false
- DarkBum.SPAWNED = false
- else
- DarkBum.PAYOUT = true
- DarkBum.SPAWNED = false
- end
- end
- if Sprite:IsFinished("SpawnCoin") or Sprite:IsFinished("Steal") or Sprite:IsFinished("AltSteal") then
- Sprite:Play("FloatDown", true)
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_FAMILIAR_UPDATE, Mod.onPickup, FamiliarVariant.DARK_BUM)
Advertisement
Add Comment
Please, Sign In to add comment