Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <items gfxroot="gfx/items/" version="1">
- <passive cache="luck" description="What's hidden inside?" name="Toy Skull" gfx="toyskull.png" />
- </items>
- ______________________________________
- <ItemPools>
- <Pool Name="treasure">
- <Item Name="Toy Skull" Weight="1" DecreasedBy="0,5" RemoveOn="0,1" />
- </Pool>
- </ItemPools>
- ______________________________________________
- <costumes anm2root="gfx/charaters/">
- <costume anm2path="toySkull.anm2" type="none" />
- </costumes>
- ___________________________________
- local ToySkullMod = RegisterMod("ToySkull", 1)
- local game = Game()
- -- reference item, costume, luck boost, Shell Game Beggar and beggar states
- ToySkullMod.COLLECTIBLE_TOYSKULL = Isaac.GetItemIdByName("Toy Skull")
- ToySkullMod.COSTUME_TOYSKULL = Isaac.GetCostumeIdByPath("gfx/characters/toySkull.anm2")
- Skull.LUCK_TOYSKULL = 2
- Shell.SKULL_BEGGAR = Isaac.GetEntityVariantByName ("Shell Game Beggar")
- BeggarState = {
- PAYPRIZE = 3,
- PRIZE = 4
- }
- function ToySkullMod:onUpdate(player)
- if game:GetFrameCount() == 1 then
- ToySkullMod.HasToySkull = false
- -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, ToySkullMod.COLLECTIBLE_TOYSKULL, Vector(320, 300), Vector(0,0), player) -- spawn in if necessary
- end
- if not ToySkullMod.HasToySkull and player:HasCollectible(ToySkullMod.COLLECTIBLE_TOYSKULL) then
- player:AddNullCostume(ToySkullMod.COSTUME_TOYSKULL)
- ToySkullMod.HasToySkull = true
- end
- end
- ToySkullMod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, ToySkullMod.onUpdate)
- -- update the cache/luck
- function ToySkullMod:onCache(player, cacheFlag)
- if cacheFlag == CacheFlag.CACHE_LUCK then
- if player:HasCollectible(ToySkullMod.COLLECTIBLE_TOYSKULL) then
- player.Luck = player.Luck + Skull.LUCK_TOYSKULL
- end
- end
- end
- ToySkullMod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, ToySkullMod.onCache)
- -- Toy Skull functionality
- function ToySkullMod:onBeggarPayout(entity)
- local player = Isaac.GetPlayer(0)
- local entities = Isaac.GetRoomEntities()
- if player:HasCollectible(ToySkullMod.COLLECTIBLE_TOYSKULL) then
- if entity.State == BeggarState.PAYPRIZE then -- check the state of the beggar. Does he pay out?
- if entity.StateFrame == 0 then -- check at the beginn of the state
- for j = 1, #entities do -- check all enities in the room
- if entities[j].Type == EntityType.ENTITY_PICKUP -- is the entity a pickup?
- and entities[j].Variant == PickupVariant.PICKUP_COIN -- is it a coin?
- and entities[j].SubType == CoinSubType.COIN_PENNY then -- and a penny?
- if entities[j].FrameCount == 1 then -- is it new?
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_GRAB_BAG, 0, true) -- change the penny into a sack
- end
- end
- if entities[j].Type == EntityType.ENTITY_PICKUP -- do the same for normal keys
- and entities[j].Variant == PickupVariant.PICKUP_KEY
- and entities[j].SubType == KeySubType.KEY_NORMAL then
- if entities[j].FrameCount == 1 then
- local rng = Isaac.GetCollectibleRNG(ToySkullMod.COLLECTIBLE_TOYSKULL)
- local pillRandom = rng:RandomInt(NUM_PILL_EFFECTS) -- gives you a random pill id
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVarint.PICKUP_PILL, pillRandom, true) -- change the normal key into a random pill
- end
- end
- if entities[j].Type == EntityType.ENTITY_PICKUP -- do the same for normal bombs
- and entities[j].Variant == PickupVariant.PICKUP_BOMB
- and entities[j].SubType == BombSubType.BOMB_NORMAL then
- if entities[j].FrameCount == 1 then
- local rng = Isaac.GetCollectibleRNG(ToySkullMod.COLLECTIBLE_TOYSKULL)
- local runeRandom = rng:RandomInt(100)
- if runeRandom < 10 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_HAGALAZ, true)
- elseif runeRandom < 20 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_JERA, true)
- elseif runeRandom < 30 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_EHWAZ, true)
- elseif runeRandom < 40 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_DAGAZ, true)
- elseif runeRandom < 50 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_ANSUZ, true)
- elseif runeRandom < 60 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_PERTHRO, true)
- elseif runeRandom < 70 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_BERKANO, true)
- elseif runeRandom < 80 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_ALGIZ, true)
- elseif runeRandom < 90 then
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_BLANK, true)
- else
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_BLACK, true)
- end
- end
- end
- end
- end
- end
- end
- -- the Shell Game Beggar "item pool"
- if not player:HasCollectible(ToySkullMod.COLLECTIBLE_TOYSKULL) then -- only works if you dont have the Toy Skull
- if entity.State == BeggarState.PRIZE then -- check the beggar state
- if entity.StateFrame == 0 then -- at the beginn of the state
- for j = 1, #entities do -- check all room entities again
- if entities[j].Type == EntityType.ENTITY_PICKUP -- check for Skatole
- and entities[j].Variant == PickupVariant.PICKUP_COLLECTIBLE
- and entities[j].SubType == CollectibleType.COLLECTIBLE_SKATOLE then
- if entities[j].FrameCount == 1 then
- local rng = Isaac.GetCollectibleRNG(ToySkullMod.COLLECTIBLE_TOYSKULL)
- local skullRandom = rng:RandomInt(100)
- if skullRandom < 50 then -- 50% chance to get the Toy Skull
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, ToySkullMod.COLLECTIBLE_TOYSKULL, true)
- esle
- entities[j]:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_SKATOLE, true)
- end
- end
- end
- end
- end
- end
- end
- end
- ToySkullMod:AddCallback(ModCallbacks.MC_NPC_UPDATE, ToySkullMod.onBeggarPayout, Shell.SKULL_BEGGAR)
Add Comment
Please, Sign In to add comment