Crooked Penny, Liberty Cap, dynamic Luck modifier (#698)

* crooked penny, luck strings

* Old Bandage chance

* Crooked Penny, liberty cap and such

* Luck modifier

* Crooked Penny, Liberty Cap, reduce repeat code

* Luck text color, Luck formula table

* Mama Mega change

* Higher chance from nickels and dimes

* Golden Bomb check

* Mama Mega conditional

* Black Feather co-op support
This commit is contained in:
Buurazu authored and GitHub committed 2024-07-23 15:19:43 +02:00
1 parent 426401c844
commit 92e01fa6e3
8 files changed
+213 -71

No files matched your search

+1
View File
@@ -302,6 +302,7 @@ if EID.isRepentance then
EID:AddSynergyConditional(720, 543, "White Poop Jar")
EID:AddSynergyConditional(720, 202, "Golden Poop Jar")
end
EID:AddConditional(483, EID.PlayersHaveGoldenBomb)
-- AB+ only misc conditionals
if not EID.isRepentance then
+10
View File
@@ -275,6 +275,16 @@ function EID:ConditionalCharCheck(playerType, includeTainted)
end
end
function EID:PlayersHaveGoldenBomb()
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
if player:HasGoldenBomb() then
return true
end
end
return false
end
function EID:IsGreedMode()
return game:IsGreedMode()
end
+13
View File
@@ -745,6 +745,11 @@ EID.InlineColors = {
["BlinkBlue"] = function(_)
return SwagColors({KColor(0.341, 0.529, 0.906, 1), KColor(0.592, 0.717, 0.937, 1)})
end,
-- Subtle glow between green from Luck Clover and from the Quality 1 shield
["BlinkGreen"] = function(_)
local c = EID.InlineColors
return SwagColors({KColor(0.404, 0.663, 0.306, 1), KColor(0.443, 0.765, 0.247, 1)})
end,
-- Shiny purple color effect
["ColorShinyPurple"] = function(_)
return SwagColors({KColor(0.812, 0.627, 1, 1), KColor(0.62, 0.251, 1, 1)}, 40)
@@ -1027,6 +1032,14 @@ EID.blackFeatherItems = {[215]=true,[216]=true,[230]=true,[260]=true,[262]=true,
if EID.isRepentance then EID.blackFeatherItems[654] = true end
EID.blackFeatherTrinkets = {[17]=true,[22]=true}
-- Luck formulas
EID.LuckFormulas = {}
EID.LuckFormulas["5.100.219"] = function(luck) return math.min(100 / (10 - math.floor(luck*0.3)), 50) end -- Old Bandage: Base 10%, 50% at 26.67 Luck
if EID.isRepentance then
EID.LuckFormulas["5.100.219"] = function(luck) return (20 + luck) end -- Old Bandage: Base 20%, 100% at 80 Luck
EID.LuckFormulas["5.100.576"] = function(luck) return math.min(luck*0.5 + 6.25, 10) end -- Dirty Mind: Base 6.25%, 10% at 7.5 Luck
end
---------------- BAG OF CRAFTING DATA ------------------
+51 -25
View File
@@ -95,10 +95,7 @@ EID.ItemReminderDescriptionModifier = {
modifierFunction = function(descObj, player)
local zodiacItem = player:GetZodiacEffect()
if zodiacItem > 0 then
local demoDescObj = EID:getDescriptionObj(5, 100, zodiacItem)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = demoDescObj.Icon
descObj.Description = demoDescObj.Description
descObj = EID:ItemReminderReplaceWithResult(descObj, zodiacItem)
return true
end
end
@@ -269,24 +266,25 @@ EID.ItemReminderDescriptionModifier = {
end
end
},
["5.100.485"] = { -- Crooked Penny
isCheat = true,
modifierFunction = function(descObj, player, inOverview)
EID:ItemReminderAddResult(descObj, EID:CrookedPennyPrediction(EID:GetItemSeed(player, 485), player:HasCollectible(356)), inOverview)
return true
end
},
["5.100.488"] = { -- Metronome
isCheat = true,
modifierFunction = function(descObj, player)
local predictionItem = EID:MetronomePrediction(EID:GetItemSeed(player, 488))
local demoDescObj = EID:getDescriptionObj(5, 100, predictionItem)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = demoDescObj.Icon
descObj.Description = demoDescObj.Description
descObj = EID:ItemReminderReplaceWithResult(descObj, predictionItem)
return true
end
},
["5.100.489"] = { -- D Infinity
modifierFunction = function(descObj, player)
local predictionItem = EID:CurrentDInfinity(EID:GetItemSeed(player, 489), player)
local demoDescObj = EID:getDescriptionObj(5, 100, predictionItem)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = demoDescObj.Icon
descObj.Description = demoDescObj.Description
descObj = EID:ItemReminderReplaceWithResult(descObj, predictionItem)
return true
end
},
@@ -337,16 +335,23 @@ EID.ItemReminderDescriptionModifier = {
end
end
},
["5.350.32"] = { -- Liberty Cap
isHiddenInfo = true,
modifierFunction = function(descObj, _)
local result = EID:LibertyCapPrediction(player)
if result then
descObj = EID:ItemReminderReplaceWithResult(descObj, result)
return true
end
end
},
["5.350.64"] = { -- Rainbow Worm
isHiddenInfo = true,
modifierFunction = function(descObj, _)
-- Rainbow Worm's trinket IDs it grants, in order
local rainbowWormEffects = { [0] = 9, 11, 65, 27, 10, 12, 26, 66, 96, 144 }
local trinketID = rainbowWormEffects[math.floor(game.TimeCounter / 30 / 3) % (EID.isRepentance and 10 or 8)]
local demoDescObj = EID:getDescriptionObj(5, 350, trinketID)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = demoDescObj.Icon
descObj.Description = demoDescObj.Description
descObj = EID:ItemReminderReplaceWithResult(descObj, trinketID, 350)
return true
end
},
@@ -355,14 +360,30 @@ EID.ItemReminderDescriptionModifier = {
modifierFunction = function(descObj, player)
local seed = game:GetLevel():GetCurrentRoom():GetSpawnSeed()
local result = EID:RNGNext(seed, 2, 7, 25) % (EID.isRepentance and 189 or 128) + 1
local demoDescObj = EID:getDescriptionObj(5, 350, result)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = demoDescObj.Icon
descObj.Description = demoDescObj.Description
descObj = EID:ItemReminderReplaceWithResult(descObj, result, 350)
return true
end
},
["5.350.132"] = { -- Broken Syringe
isHiddenInfo = true,
modifierFunction = function(descObj, _)
local result = EID:BrokenSyringePrediction(player)
if result then
descObj = EID:ItemReminderReplaceWithResult(descObj, result)
return true
end
end
},
["5.350.153"] = { -- Mom's Lock
isHiddenInfo = true,
modifierFunction = function(descObj, _)
local result = EID:MomsLockPrediction(player)
if result then
descObj = EID:ItemReminderReplaceWithResult(descObj, result)
return true
end
end
},
["5.350.166"] = { -- Modeling Clay
isRepentance = true,
modifierFunction = function(descObj, player)
@@ -370,10 +391,7 @@ EID.ItemReminderDescriptionModifier = {
if EID.Config["ItemReminderShowHiddenInfo"] or player:GetTrinket(0) == 166 or player:GetTrinket(1) == 166 then
local modelingClayItem = player:GetModelingClayEffect()
if modelingClayItem > 0 then
local demoDescObj = EID:getDescriptionObj(5, 100, modelingClayItem)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = "{{Collectible" .. modelingClayItem .. "}}"
descObj.Description = demoDescObj.Description
descObj = EID:ItemReminderReplaceWithResult(descObj, modelingClayItem)
return true
end
end
@@ -420,6 +438,14 @@ function EID:ItemReminderAddResult(descObj, newText, inOverview)
EID:ItemReminderAddResultAppend(descObj, newText)
end
end
-- Helper function for modifiers like Modeling Clay / Liberty Cap that replace their description with the temporary item's description
function EID:ItemReminderReplaceWithResult(descObj, result, resultVariant)
local demoDescObj = EID:getDescriptionObj(5, resultVariant or 100, result)
EID:ItemReminderAddResultHeaderSuffix(descObj, demoDescObj.Name)
descObj.Icon = "{{" .. EID:GetIconNameByVariant(resultVariant or 100) .. result .. "}}"
descObj.Description = demoDescObj.Description
return true
end
-- Add item description for a given entity to the reminder. Also tries to apply special modifiers if present
function EID:ItemReminderAddDescription(player, entityType, variant, subType, extraIcon)
+61 -2
View File
@@ -1,10 +1,28 @@
-- This file is for various functions that are able to calculate the result effect that an item will have
local game = Game()
local variantToName = { [70] = "Pill", [100] = "Collectible", [300] = "Card", [350] = "Trinket" }
-- XOR table used for RNG: https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf
local xortable = {
[0]={ 1, 3,10},{ 1, 5,16},{ 1, 5,19},{ 1, 9,29},{ 1,11, 6},{ 1,11,16},{ 1,19, 3},{ 1,21,20},{ 1,27,27},
{ 2, 5,15},{ 2, 5,21},{ 2, 7, 7},{ 2, 7, 9},{ 2, 7,25},{ 2, 9,15},{ 2,15,17},{ 2,15,25},{ 2,21, 9},
{ 3, 1,14},{ 3, 3,26},{ 3, 3,28},{ 3, 3,29},{ 3, 5,20},{ 3, 5,22},{ 3, 5,25},{ 3, 7,29},{ 3,13, 7},
{ 3,23,25},{ 3,25,24},{ 3,27,11},{ 4, 3,17},{ 4, 3,27},{ 4, 5,15},{ 5, 3,21},{ 5, 7,22},{ 5, 9,7 },
{ 5, 9,28},{ 5, 9,31},{ 5,13, 6},{ 5,15,17},{ 5,17,13},{ 5,21,12},{ 5,27, 8},{ 5,27,21},{ 5,27,25},
{ 5,27,28},{ 6, 1,11},{ 6, 3,17},{ 6,17, 9},{ 6,21, 7},{ 6,21,13},{ 7, 1, 9},{ 7, 1,18},{ 7, 1,25},
{ 7,13,25},{ 7,17,21},{ 7,25,12},{ 7,25,20},{ 8, 7,23},{ 8,9,23 },{ 9, 5,1 },{ 9, 5,25},{ 9,11,19},
{ 9,21,16},{10, 9,21},{10, 9,25},{11, 7,12},{11, 7,16},{11,17,13},{11,21,13},{12, 9,23},{13, 3,17},
{13, 3,27},{13, 5,19},{13,17,15},{14, 1,15},{14,13,15},{15, 1,29},{17,15,20},{17,15,23},{17,15,26}
}
-- reimplementation of RNG:Next()
-- Default RNG shift values for many things are 5, 9, 7
-- Default RNG shift values for many things are 5, 9, 7 (xor table #35)
function EID:RNGNext(rngNum, shift1, shift2, shift3)
if shift1 and not shift2 then
shift3 = xortable[shift1][3]
shift2 = xortable[shift1][2]
shift1 = xortable[shift1][1]
end
rngNum = rngNum ~ ((rngNum >> (shift1 or 5)) & 4294967295)
rngNum = rngNum ~ ((rngNum << (shift2 or 9)) & 4294967295)
rngNum = rngNum ~ ((rngNum >> (shift3 or 7)) & 4294967295)
@@ -17,6 +35,7 @@ function EID:SeedToFloat(seed)
return seed * multi;
end
-- D Infinity --
local dinfinityList = { [0] = 105, 166, 284, 283, 285, 406, 386 }
-- Repentance's D Infinity order: D1, D4, D6, Eternal D6, D7, D8, D10, D12, D20, D100
@@ -396,3 +415,43 @@ function EID:GlyphOfBalancePrediction(player)
return pickupNames[fullID] or EID:GetEntityXMLNameByString(fullID) or fullID
end
--- Crooked Penny ---
function EID:CrookedPennyPrediction(rng, carBattery)
local rng = EID:RNGNext(rng)
local seed = rng
-- Repentance makes a new seed by XORing the room's decoration seed
if EID.isRepentance then
local roomSeed = game:GetLevel():GetCurrentRoom():GetDecorationSeed()
seed = seed ~ roomSeed
if seed == 0 then seed = 1 end
seed = EID:RNGNext(seed, 4) -- xorshift #4
end
local result = ""
if seed % 2 == 0 then
result = EID:getDescriptionEntry("CrookedPennyHeads")
else
result = EID:getDescriptionEntry("CrookedPennyTails")
-- failures advance crooked penny's RNG an additional time to give the pity penny a seed value
rng = EID:RNGNext(rng)
end
if carBattery then return result .. "#{{Collectible356}} " .. EID:CrookedPennyPrediction(rng)
else return result end
end
-- Liberty Cap, Broken Syringe, Mom's Lock (extremely similar, simple RNG modulos) --
local libertyItems = {[0] = 21, 71, 120, 121}
if EID.isRepentance then libertyItems = {[0] = 12, 71, 120, 121, 342, 398} end
local syringeItems = {[0] = 13, 14, 240, 70, 143, 345, 493, 496}
local momItems = {[0] = 29, 30, 31, 55, 110, 114, 199, 200, 217, 228, 355, 508, 732}
function EID:TemporaryEffectPrediction(player, rng, itemTable)
local tempItem = itemTable[rng % #itemTable]
if player:GetEffects():HasCollectibleEffect(tempItem) then return tempItem else return false end
end
function EID:LibertyCapPrediction(player) return EID:TemporaryEffectPrediction(player, player:GetTrinketRNG(32):GetSeed(), libertyItems) end
function EID:BrokenSyringePrediction(player) return EID:TemporaryEffectPrediction(player, player:GetTrinketRNG(132):GetSeed(), syringeItems) end
function EID:MomsLockPrediction(player) return EID:TemporaryEffectPrediction(player, player:GetTrinketRNG(153):GetSeed(), momItems) end
-- dont forget to actually add these to hold map desc; remember these are Hidden Information
+63 -37
View File
@@ -222,31 +222,36 @@ local function SacrificeRoomCallback(descObj)
end
-- Handle Black Feather dynamic damage up text
-- TODO: Make this co-op friendly, add conditionals to the black feather items
local function BlackFeatherCallback(descObj)
local itemCounter = 0
for itemID, _ in pairs(EID.blackFeatherItems) do
itemCounter = itemCounter + EID.player:GetCollectibleNum(itemID)
end
for trinketID, _ in pairs(EID.blackFeatherTrinkets) do
if EID.isRepentance then
itemCounter = itemCounter + EID.player:GetTrinketMultiplier(trinketID)
else
if EID.player:HasTrinket(trinketID) then itemCounter = itemCounter + 1 end
for i = 1,#EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
local playerType = player:GetPlayerType()
local itemCounter = 0
for itemID, _ in pairs(EID.blackFeatherItems) do
itemCounter = itemCounter + player:GetCollectibleNum(itemID)
end
for trinketID, _ in pairs(EID.blackFeatherTrinkets) do
if EID.isRepentance then
itemCounter = itemCounter + player:GetTrinketMultiplier(trinketID)
else
if player:HasTrinket(trinketID) then itemCounter = itemCounter + 1 end
end
end
local hasBox = player:HasCollectible(439)
local isGolden = EID.isRepentance and ((descObj.ObjSubType & TrinketType.TRINKET_GOLDEN_FLAG) == TrinketType.TRINKET_GOLDEN_FLAG)
local base = EID.isRepentance and 0.5 or 0.2
local damageMultiplied = base * itemCounter * (hasBox and 2 or 1) * (isGolden and 2 or 1)
local dmgColor = itemCounter == 0 and "CR" or (hasBox or isGolden) and "ColorGold" or "BlinkGray"
local description = EID:getDescriptionEntry("BlackFeatherInformation")
description, _ = EID:ReplaceVariableStr(description, 1, tostring(itemCounter))
description, _ = EID:ReplaceVariableStr(description, 2, "{{"..dmgColor.."}}"..damageMultiplied.."{{CR}}")
if #EID.coopAllPlayers > 1 then description = EID:GetPlayerIcon(playerType, "P" .. i .. ":") .. " " .. description end
EID:appendToDescription(descObj, "# "..description)
end
local hasBox = EID.player:HasCollectible(439)
local isGolden = EID.isRepentance and ((descObj.ObjSubType & TrinketType.TRINKET_GOLDEN_FLAG) == TrinketType.TRINKET_GOLDEN_FLAG)
local base = EID.isRepentance and 0.5 or 0.2
local damageMultiplied = base * itemCounter * (hasBox and 2 or 1) * (isGolden and 2 or 1)
local dmgColor = itemCounter == 0 and "CR" or (hasBox or isGolden) and "ColorGold" or "BlinkGray"
local description = EID:getDescriptionEntry("BlackFeatherInformation")
description, _ = EID:ReplaceVariableStr(description, 1, tostring(itemCounter))
description, _ = EID:ReplaceVariableStr(description, 2, "{{"..dmgColor.."}}"..damageMultiplied.."{{CR}}")
EID:appendToDescription(descObj, "# "..description)
return descObj
end
@@ -284,6 +289,26 @@ local function VurpCallback(descObj)
return descObj
end
-- Handle dynamic Luck chance modifiers
local function LuckChanceCallback(descObj)
for i = 1,#EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
if player.Luck ~= 0 then
local playerType = player:GetPlayerType()
local result = math.max(math.min(EID.LuckFormulas[descObj.fullItemString](player.Luck), 100), 0)
local luckLine = EID:getDescriptionEntry("LuckModifier")
luckLine = EID:ReplaceVariableStr(luckLine, 1, string.format("%.3g", result))
luckLine = EID:ReplaceVariableStr(luckLine, 2, "{{BlinkGreen}}" .. string.format("%.3g", player.Luck) .. "{{CR}}")
if #EID.coopAllPlayers == 1 then EID:appendToDescription(descObj, "#{{Luck}} ")
else EID:appendToDescription(descObj, "#" .. EID:GetPlayerIcon(playerType, "P" .. i .. ":") .. " ") end
EID:appendToDescription(descObj, "{{NoLB}}" .. luckLine)
end
end
return descObj
end
if EID.isRepentance then
-- Handle Birthright
local function BirthrightCallback(descObj)
@@ -304,21 +329,21 @@ if EID.isRepentance then
return descObj
end
-- Handle Glowing Hourglass changed back into Hourglass description
local function GlowingHourglassCallback(descObj)
if REPENTOGON and EID.collectiblesOwned[422] then
local transformedText = EID:getDescriptionEntry("GlowingHourglassTransformed")
local numUses = Isaac.GetPlayer(EID.collectiblesOwned[422]):GetActiveItemDesc().VarData
if numUses == 3 then
-- Replace with the description of The Hourglass
descObj.Description = EID:getDescriptionObj(5, 100, 66).Description
if transformedText ~= nil then
EID:appendToDescription(descObj, "#{{Warning}} "..transformedText)
end
end
end
return descObj
end
-- Handle Glowing Hourglass changed back into Hourglass description
local function GlowingHourglassCallback(descObj)
if REPENTOGON and EID.collectiblesOwned[422] then
local transformedText = EID:getDescriptionEntry("GlowingHourglassTransformed")
local numUses = Isaac.GetPlayer(EID.collectiblesOwned[422]):GetActiveItemDesc().VarData
if numUses == 3 then
-- Replace with the description of The Hourglass
descObj.Description = EID:getDescriptionObj(5, 100, 66).Description
if transformedText ~= nil then
EID:appendToDescription(descObj, "#{{Warning}} "..transformedText)
end
end
end
return descObj
end
-- Handle Book of Virtues description addition
local function BookOfVirtuesCallback(descObj)
@@ -872,6 +897,7 @@ local function EIDConditionsAB(descObj)
local callbacks = {}
if EID.LuckFormulas[descObj.fullItemString] then table.insert(callbacks, LuckChanceCallback) end
-- Collectible Pedestal Callbacks
if descObj.ObjVariant == PickupVariant.PICKUP_COLLECTIBLE then
if EID.Config["ItemCollectionIndicator"] and EID:requiredForCollectionPage(descObj.ObjSubType) then table.insert(callbacks, ItemCollectionPageCallback) end