Health Up modifier for non-red characters + misc (#710)

* Health up / different effect modifiers

* ClosestPlayerTo, move utility functions

* ClosestPlayer adds to DifferentEffectPlayers table

* More data tables for Health Ups

* useless Lost items, comment the health mod atm

* HealingRed, RedToX

* HealingRed added

* Moving Pluralize

* oops

* Move Pluralize

* Move Pluralize

* allow choosing the position of modifiers in the table

* default layer to 0

* Changes to no red char conditions

* Support healing items in the modifier

* tweaks to health up data

* Support {1} in Result Header

* {1} in ResultHeader

* Tweak binge eater wording

* reword comment
This commit is contained in:
Buurazu authored and GitHub committed 2024-08-19 19:52:56 +02:00
1 parent 9d8a2ae730
commit e271302f69
29 files changed
+355 -230

No files matched your search

+39 -47
View File
@@ -161,7 +161,7 @@ end
noFallback: Don't fallback to English if this isn't localized; by default, conditionals don't fallback, to avoid printing English text in unupdated languages
usePedestalName: If true, display the pedestal item's name in place of {1}
useResult: If true, use the result from the conditional function to find the localization string
layer: A number used in determining the order that conditionals should be checked in, default -1
layer: A number used in determining the order that conditionals should be checked in, default 0
checkLayers: If true, don't print this condition if a higher layer condition was applied already
uniqueID: Only one conditional with the given unique ID will be printed
]]
@@ -175,7 +175,7 @@ function EID:AddConditional(IDs, funcText, modText, extraTable)
if modText == "" then modText = nil end
extraTable = extraTable or {}
if extraTable.noFallback == nil then extraTable.noFallback = true end
extraTable.layer = extraTable.layer or -1
extraTable.layer = extraTable.layer or 0
for _, id in ipairs(IDs) do
if type(id) ~= "string" then id = "5.100." .. id end
EID.DescriptionConditions[id] = EID.DescriptionConditions[id] or {}
@@ -288,25 +288,33 @@ end
function EID:ClosestCharCheck(modifierText, playerTypes, includeTainted)
if EID.InsideItemReminder or not EID.CurrentConditionalDescObj.Entity then return modifierText end
if type(playerTypes) ~= "table" then playerTypes = {playerTypes} end
local closestDist = 9999999
local closestPlayer = EID.player
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
local dist = player.Position:Distance(EID.CurrentConditionalDescObj.Entity.Position)
if dist < closestDist then
closestDist = dist
closestPlayer = player
local closestPlayer = EID:ClosestPlayerTo(EID.CurrentConditionalDescObj.Entity)
if EID:ArrayContains(playerTypes, closestPlayer:GetPlayerType()) or (includeTainted and EID:ArrayContains(playerTypes, EID.TaintedToRegularID[closestPlayer:GetPlayerType()])) then
-- The closest player applies the modifier; check for players that don't get this modifier
for i = 1, #EID.coopAllPlayers do
local t = EID.coopAllPlayers[i]:GetPlayerType()
if not (EID:ArrayContains(playerTypes, t) or (includeTainted and EID:ArrayContains(playerTypes, EID.TaintedToRegularID[t]))) then
table.insert(EID.DifferentEffectPlayers, t)
end
end
return modifierText
end
if EID:ArrayContains(playerTypes, closestPlayer:GetPlayerType()) or (includeTainted and EID:ArrayContains(playerTypes, EID.TaintedToRegularID[closestPlayer:GetPlayerType()])) then return modifierText end
return "Different Effect"
-- The closest player does not apply the modifier; check for players that do get this modifier
for i = 1, #EID.coopAllPlayers do
local t = EID.coopAllPlayers[i]:GetPlayerType()
if EID:ArrayContains(playerTypes, t) or (includeTainted and EID:ArrayContains(playerTypes, EID.TaintedToRegularID[t])) then
table.insert(EID.DifferentEffectPlayers, t)
end
end
return "N/A"
end
function EID:PlayersHaveGoldenBomb()
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
if player:HasGoldenBomb() then
return true
end
@@ -349,8 +357,8 @@ function EID:CheckForNoRedHealthPlayer()
local player = EID.ItemReminderPlayerEntity
return EID.NoRedHeartsPlayerIDs[player:GetPlayerType()]
else
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
if EID.NoRedHeartsPlayerIDs[player:GetPlayerType()] then
return true
end
@@ -364,8 +372,8 @@ function EID:CheckForTaintedPlayer()
local player = EID.ItemReminderPlayerEntity
return EID.TaintedIDs[player:GetPlayerType()]
else
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
if EID.TaintedIDs[player:GetPlayerType()] then
return true
end
@@ -382,8 +390,8 @@ function EID:CheckForMultipleActives(descObj, onlyChargeablePockets)
local id = player:GetPlayerType()
if EID.isRepentance and (EID.PocketActivePlayerIDs[id] == 0 or (not onlyChargeablePockets and EID.PocketActivePlayerIDs[id])) then return player:GetActiveItem(2) end
else
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
if player:HasCollectible(534) then return 534 end
local id = player:GetPlayerType()
if EID.isRepentance and (EID.PocketActivePlayerIDs[id] == 0 or (not onlyChargeablePockets and EID.PocketActivePlayerIDs[id])) then return player:GetActiveItem(2) end
@@ -401,8 +409,8 @@ function EID:CheckForPocketActives()
local player = EID.ItemReminderPlayerEntity
return EID.PocketActivePlayerIDs[player:GetPlayerType()]
else
for i = 0, game:GetNumPlayers() - 1 do
local player = Isaac.GetPlayer(i)
for i = 1, #EID.coopAllPlayers do
local player = EID.coopAllPlayers[i]
if EID.PocketActivePlayerIDs[player:GetPlayerType()] then return true end
end
end
@@ -473,9 +481,7 @@ function EID:CheckPlayersForActiveChargeType(maxCharge, chargeType, checkPockets
if EID.InsideItemReminder then
players[1] = EID:ItemReminderGetAllPlayers()[EID.ItemReminderSelectedPlayer + 1] or EID.player
else
for i = 0, game:GetNumPlayers() - 1 do
table.insert(players, Isaac.GetPlayer(i))
end
players = EID.coopAllPlayers
end
local maxSlot = EID.isRepentance and 1 or 0
if EID.isRepentance and checkPockets then maxSlot = 3 end
@@ -506,9 +512,9 @@ function EID:CheckActiveChargeType(itemID, maxCharge, chargeType, requiredCollec
return false
end
-- Check for multiple players existing for items like Yum Heart and Extension Cord, includes J&E (but does it include Forgotten?)
-- Check for multiple players existing for items like Yum Heart and Extension Cord, includes J&E and Strawmen
function EID:MultiplePlayerCharacters()
return #EID.coopAllPlayers > 1
return game:GetNumPlayers() > 1
end
-- Check the bestiary/character list if we have REPENTOGON, to help avoid spoilers. Otherwise just return true
@@ -535,24 +541,10 @@ end
----- Apply Conditionals -----
-- thing to fix find/replace pairs with hyphens (like "1-2") breaking because hyphen is a special char
-- https://stackoverflow.com/questions/29072601/lua-string-gsub-with-a-hyphen
local function replace(str, what, with, count)
what = string.gsub(what, "[%(%)%.%+%-%*%?%[%]%^%$%%]", "%%%1") -- escape pattern
with = string.gsub(with, "[%%]", "%%%%") -- escape replacement
return string.gsub(str, what, with, count)
end
EID.testReplace = replace
-- super simple table concatenation: https://www.tutorialspoint.com/concatenation-of-tables-in-lua-programming
local function TableConcat(t1, t2)
for i = 1, #t2 do
t1[#t1 + 1] = t2[i]
end
return t1
end
EID.CurrentConditionalDescObj = nil
function EID:applyConditionals(descObj)
EID.CurrentConditionalDescObj = descObj
EID.DifferentEffectPlayers = {}
EID:CheckPlayersCollectibles()
local adjustedSubtype = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType)
local typeVar = descObj.ObjType.."."..descObj.ObjVariant -- for general conditions (Tarot Cloth, Book of Virtues)
@@ -562,8 +554,8 @@ function EID:applyConditionals(descObj)
-- Combine specific+generic conditions into one table (in that order)
local conds = {}
if EID.DescriptionConditions[typeVarSub] then TableConcat(conds, EID.DescriptionConditions[typeVarSub]) end
if EID.DescriptionConditions[typeVar] then TableConcat(conds, EID.DescriptionConditions[typeVar]) end
if EID.DescriptionConditions[typeVarSub] then EID:ConcatTables(conds, EID.DescriptionConditions[typeVarSub]) end
if EID.DescriptionConditions[typeVar] then EID:ConcatTables(conds, EID.DescriptionConditions[typeVar]) end
table.sort(conds, function(a, b) return a.layer > b.layer end)
-- Check every condition we need to check for this item
for _, cond in ipairs(conds) do
@@ -616,7 +608,7 @@ function EID:applyConditionals(descObj)
-- Table with 1 entry = replace
elseif #text == 1 then
descObj.Description = EID:ReplaceVariableStr(text[1], variableText)
-- Table with 2+ entries = find and replace pairs
-- Entry 1 is replaced with entry 2, entry 3 is replaced with entry 4, etc.
-- If there's an odd number of entries, the last one is appended
@@ -636,9 +628,9 @@ function EID:applyConditionals(descObj)
return replaceWith
end
end)
-- Basic find+replace for non-numbers
-- Basic find+replace for non-numbers
else
descObj.Description = replace(descObj.Description, tostring(toFind), replaceWith, 1)
descObj.Description = EID:SimpleReplace(descObj.Description, tostring(toFind), replaceWith, 1)
end
else
toFind = EID:ReplaceVariableStr(toFind, variableText)