Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ToySkull = RegisterMod("ToySkull", 1)
- local game = Game()
- --reference item & costume
- CollectibleType.COLLECTIBLE_TOY_SKULL = Isaac.GetItemIdByName("Toy Skull")
- ToySkull.COSTUME_TOY_SKULL = Isaac.GetCostumeIdByPath("gfx/characters/toyskull.anm2")
- local ToyBonus = {
- TOYSKULL = 2 --Luck
- }
- --Shell Game tables
- local Grab = {
- Coin = nil,
- Key = nil,
- Bomb = nil
- }
- local Shell = {
- Traget = nil,
- RADIUS = 4
- }
- local pickup = {}
- --update the inventory
- local function UpdateToy(player)
- HasToy.ToySkull = player:HasCollectible(CollectibleType.COLLECTIBLE_TOY_SKULL)
- end
- --if you start a run or continue. Before anything happens
- function ToySkull:onPlayerInit(player)
- UpdateToy(player)
- end
- ToySkull:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, ToySkull.onPlayerInit)
- --when passive effects should update
- function ToySkull:onUpdate(player)
- if game:GetFrameCount() == 1 then
- ToySkull.HasToySkull = false
- --spawn in if necessary
- end
- if not ToySkull.HasToySkull and HasToy.ToySkull then
- player:AddNullCostume(ToySkull.COSTUME_TOY_SKULL)
- ToySkull.HasToySkull = true
- end
- UpdateToy(player)
- end
- ToySkull:AddCallback(Modcallbacks.MC_POST_PEFFECT_UPDATE, ToySkull.onUpdate)
- --update the cache
- function ToySkull:onCache(player, cacheFlag)
- if cacheFlag == CacheFlag.CACHE_LUCK then
- if player:HasCollectible(CollectibleType.COLLECTIBLE_TOY_SKULL) and not HasToy.ToySkull then
- player.Luck = player.Luck + ToyBonus.ToySkull
- end
- end
- end
- ToySkull:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, ToySkull.onCache)
- --add Shell Game functionality
- function ToySkull.onPayout()
- --is there a Shell Game Beggar in the room?
- if HasToy.ToySkull and Shell.Target == nil then
- local roomEntities = Isaac.GetRoomEntities()
- local shellGame = Isaac:GetEntityVariantByName("Shell Game Beggar")
- for i, entity in pairs(roomEntities) do
- if entity.Type == EntityType.ENTITY_SLOT
- and entity.Variant == shellGame then
- Shell.Target = entity
- end
- end
- --if yes, then the game will check if he spawns a pickup. In this case a coin
- elseif Shell.Target.Spawn(EntityType.ENTITY_PICKUP)
- and pickup.Variant == PickupVariant.PICKUP_COIN
- and pickup.Subtype == CoinSubType.COIN_PENNY then
- local shellEntities = Isaac.FindInRadius(Shell.Target.Position, 100, EntityPartition.PICKUP)
- for j, grabc in pairs(shellEntities) do
- if grabc.Variant == PickupVariant.PICKUP_COIN
- and grabc.Subtype == CoinSubType.COIN_PENNY then
- Grab.Coin = grabc
- Isaac.Spawn(
- EntityType.ENTITY_PICKUP,
- PickupVariant.PICKUP_GRAB_BAG,
- Grab.Coin.Position,
- Vector(
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS,
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS
- ),
- Shell.Target
- )
- Grab.Coin:Remove()
- Grab.Coin = nil
- end
- end
- Shell.Target = nil
- --now a doublecoin
- elseif Shell.Target.Spawn(EntityType.ENTITY_PICKUP)
- and pickup.Variant == PickupVariant.PICKUP_COIN
- and pickup.Subtype == CoinSubType.COIN_DOUBLEPACK then
- local shellEntities = Isaac.FindInRadius(Shell.Target.Position, 100, EntityPartition.PICKUP)
- for k, grabc in pairs(shellEntities) do
- if grabc.Variant == PickupVariant.PICKUP_COIN
- and grabc.Subtype == CoinSubType.COIN_DOUBLEPACK then
- Grab.Coin = grabc
- Isaac.Spawn(
- EntityType.ENTITY_PICKUP,
- PickupVariant.PICKUP_GRAB_BAG,
- Grab.Coin.Position,
- Vector(
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS,
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS
- ),
- Shell.Target
- )
- Grab.Coin:Remove()
- Grab.Coin = nil
- end
- end
- Shell.Target = nil
- --now a key
- elseif Shell.Target.Spawn(EntityType.ENTITY_PICKUP)
- and pickup.Variant == PickupVariant.PICKUP_KEY
- and pickup.Subtype == KeySubType.KEY_NORMAL then
- local shellEntities = Isaac.FindInRadius(Shell.Target.Position, 100, EntityPartition.PICKUP)
- for l, grabk in pairs(shellEntities) do
- if grabk.Variant == PickupVariant.PICKUP_KEY
- and grabk.Subtype == KeySubType.KEY_NORMAL then
- Grab.Key = grabk
- Isaac.Spawn(
- EntityType.ENTITY_PICKUP,
- PickupVariant.PICKUP_PILL,
- Grab.Key.Position,
- Vector(
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS,
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS
- ),
- Shell.Target
- )
- Grab.Key:Remove()
- Grab.Key = nil
- end
- end
- Shell.Target = nil
- --now a doublekey
- elseif Shell.Target.Spawn(EntityType.ENTITY_PICKUP)
- and pickup.Variant == PickupVariant.PICKUP_KEY
- and pickup.Subtype == KeySubType.KEY_DOUBLEPACK then
- local shellEntities = Isaac.FindInRadius(Shell.Target.Position, 100, EntityPartition.PICKUP)
- for m, grabk in pairs(shellEntities) do
- if grabk.Variant == PickupVariant.PICKUP_KEY
- and grabk.Subtype == KeySubType.KEY_DOUBLEPACK then
- Grab.Key = grabk
- Isaac.Spawn(
- EntityType.ENTITY_PICKUP,
- PickupVariant.PICKUP_PILL,
- Grab.Key.Position,
- Vector(
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS,
- math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS
- ),
- Shell.Target
- )
- Grab.Key:Remove()
- Grab.Key = nil
- end
- end
- Shell.Target = nil
- --now a bomb
- elseif Shell.Target.Spawn(EntityType.ENTITY_PICKUP)
- and pickup.Variant == PickupVariant.PICKUP_BOMB
- and pickup.Subtype == BombSubType.BOMB_NORMAL then
- local shellEntities = Isaac.FindInRadius(Shell.Target.Position, 100, EntityPartition.PICKUP)
- for n, grabbo in pairs(shellEntities) do
- if grabbo.Variant == PickupVariant.PICKUP_BOMB
- and grabbo.Subtype == BombSubType.BOMB_NORMAL then
- Grab.Bomb = grabbo
- local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_TOY_SKULL)
- local roll = rng:RandomInit(20)
- if roll < 2 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_HAGALAZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- esleif roll < 4 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_JERA, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 6 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_EHWAZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 8 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_DAGAZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 10 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_ANSUZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 12 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_PERTHRO, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- esleif roll < 14 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_BERKANO, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 16 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_ALGIZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 18 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_BLANK, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- else Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_BLACK, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- end
- Grab.Bomb:Remove()
- Grab.Bomb = nil
- end
- end
- Shell.Target = nil
- --now a doublebomb
- elseif Shell.Target.Spawn(EntityType.ENTITY_PICKUP)
- and pickup.Variant == PickupVariant.PICKUP_BOMB
- and pickup.Subtype == BombSubType.BOMB_DOUBLEPACK then
- local shellEntities = Isaac.FindInRadius(Shell.Target.Position, 100, EntityPartition.PICKUP)
- for o, grabbo in pairs(shellEntities) do
- if grabbo.Variant == PickupVariant.PICKUP_BOMB
- and grabbo.Subtype == BombSubType.BOMB_DOUBLEPACK then
- Grab.Bomb = grabbo
- local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_TOY_SKULL)
- local roll = rng:RandomInit(20)
- if roll < 2 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_HAGALAZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- esleif roll < 4 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_JERA, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 6 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_EHWAZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 8 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_DAGAZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 10 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_ANSUZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 12 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_PERTHRO, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- esleif roll < 14 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_BERKANO, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 16 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_ALGIZ, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- elseif roll < 18 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_BLANK, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- else Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, CARD_RUNE_BLACK, Grab.Bomb.Position, Vector (math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS, math.random(Shell.RADIUS * 2 + 1) - Shell.RADIUS), Shell.Target)
- end
- Grab.Bomb:Remove()
- Grab.Bomb = nil
- end
- end
- Shell.Target = nil
- end
- end
- ToySkull:AddCallback(ModCallbacks.MC_POST_NPC_UPDATE, ToySkull.onPayout)
Advertisement
Add Comment
Please, Sign In to add comment