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:
1 parent
9d8a2ae730
commit
e271302f69
29 files changed
+355
-230
No files matched your search
@@ -309,13 +309,65 @@ local function LuckChanceCallback(descObj)
|
||||
return descObj
|
||||
end
|
||||
|
||||
-- Handle changing health up text for non-red HP players
|
||||
local function HealthUpCallback(descObj)
|
||||
local adjustedSubtype = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType)
|
||||
local typeVarSub = descObj.ObjType.."."..descObj.ObjVariant.."."..adjustedSubtype
|
||||
|
||||
local closestPlayer = EID:ClosestPlayerTo(descObj.Entity)
|
||||
local playerType = closestPlayer:GetPlayerType()
|
||||
local heartType = EID.CharacterToHeartType[playerType] or "Red"
|
||||
if heartType == "Red" then return descObj end
|
||||
|
||||
-- find/replace Health Up lines
|
||||
local numHearts = EID.HealthUpData[typeVarSub] or 1
|
||||
local text = EID:getDescriptionEntry("RedToX", "Red to " .. heartType)
|
||||
local plural = ""; if numHearts ~= 1 then plural = EID:getDescriptionEntry("Pluralize") end
|
||||
|
||||
local pos = 1
|
||||
while pos <= #text do
|
||||
-- replace {1} with the number of hearts and {2} with the plural character
|
||||
local toFind = EID:ReplaceVariableStr(text[pos], {numHearts, plural})
|
||||
if text[pos + 1] then
|
||||
local replaceWith = EID:ReplaceVariableStr(text[pos + 1], {numHearts, plural})
|
||||
descObj.Description = EID:SimpleReplace(descObj.Description, tostring(toFind), replaceWith, 1)
|
||||
end
|
||||
pos = pos + 2
|
||||
end
|
||||
|
||||
-- remove HealingRed lines entirely for Soul/Black/None health chars
|
||||
descObj.Description = descObj.Description .. "#" -- gsub finds final lines better if the desc ends with a line break
|
||||
if heartType == "Soul" or heartType == "Black" or heartType == "None" then
|
||||
-- Find any lines containing {{HealingRed}} or {{HealingHalfRed}} and remove the line
|
||||
descObj.Description = descObj.Description:gsub("{{HealingRed}}(.-)#", "")
|
||||
descObj.Description = descObj.Description:gsub("{{HealingHalfRed}}(.-)#", "")
|
||||
end
|
||||
|
||||
-- check if we just made the description blank
|
||||
if descObj.Description:gsub("#", "") == "" then
|
||||
local noEffectStr = EID:getDescriptionEntry("ConditionalDescs", "No Effect")
|
||||
descObj.Description = "{{Player" .. playerType .. "}} " .. EID:ReplaceVariableStr(noEffectStr, "{{NameOnlyI" .. playerType .. "}}")
|
||||
end
|
||||
|
||||
-- test the other players for if they have a different effect
|
||||
-- todo: this simple check could have false positives (i.e. Yum Heart is identical for Soul and Black, but this thinks they'll be different)
|
||||
for i = 1, #EID.coopAllPlayers do
|
||||
local t = EID.coopAllPlayers[i]:GetPlayerType()
|
||||
if EID.CharacterToHeartType[t] ~= heartType then
|
||||
table.insert(EID.DifferentEffectPlayers, t)
|
||||
end
|
||||
end
|
||||
|
||||
return descObj
|
||||
end
|
||||
|
||||
if EID.isRepentance then
|
||||
-- Handle Birthright
|
||||
local function BirthrightCallback(descObj)
|
||||
descObj.Description = ""
|
||||
local describedPlayerTypes = {}
|
||||
for i = 0,game:GetNumPlayers() - 1 do
|
||||
local player = Isaac.GetPlayer(i)
|
||||
for i = 1, #EID.coopAllPlayers do
|
||||
local player = EID.coopAllPlayers[i]
|
||||
local playerID = player:GetPlayerType()
|
||||
if not player:IsSubPlayer() and player:GetMainTwin( ):GetPlayerType() == playerID and not describedPlayerTypes[playerID] then
|
||||
describedPlayerTypes[playerID] = true
|
||||
@@ -904,6 +956,9 @@ local function EIDConditionsAB(descObj)
|
||||
local callbacks = {}
|
||||
|
||||
if EID.LuckFormulas[descObj.fullItemString] then table.insert(callbacks, LuckChanceCallback) end
|
||||
local adjustedSubtype = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType)
|
||||
local typeVarSub = descObj.ObjType.."."..descObj.ObjVariant.."."..adjustedSubtype
|
||||
if EID.HealthUpData[typeVarSub] or EID.HealingItemData[typeVarSub] then table.insert(callbacks, HealthUpCallback) 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
|
||||
@@ -922,7 +977,7 @@ local function EIDConditionsAB(descObj)
|
||||
end
|
||||
return callbacks
|
||||
end
|
||||
EID:addDescriptionModifier("EID Afterbirth+", EIDConditionsAB, nil)
|
||||
EID:addDescriptionModifier("EID Afterbirth+", EIDConditionsAB, nil, 1)
|
||||
|
||||
-- should this be done differently so that mods can add tab previews? (tab conditions is done last, but would be done before callbacks mods add, maybe tab should be checked in EID:getDescriptionObj
|
||||
local function TabConditions(_)
|
||||
@@ -930,5 +985,22 @@ local function TabConditions(_)
|
||||
EID.TabPreviewID = 0
|
||||
return false
|
||||
end
|
||||
|
||||
EID:addDescriptionModifier("EID Tab Previews", TabConditions, TabCallback)
|
||||
|
||||
-- If an item has a radically different effect for 2 players, show the effect for the closest player, then append what chars have a different effect here
|
||||
-- This is the final change made to the desc, after all other conditionals and modifiers
|
||||
local function CoopDifferentEffectCallback(descObj)
|
||||
local displayedChars = {}
|
||||
local differentEffectText = EID:getDescriptionEntry("ConditionalDescs", "Different Effect")
|
||||
for _,v in ipairs(EID.DifferentEffectPlayers) do
|
||||
if not displayedChars[v] then
|
||||
descObj.Description = descObj.Description .. "#{{Player" .. v .. "}} " .. EID:ReplaceVariableStr(differentEffectText, "{{NameOnlyI" .. v .. "}}")
|
||||
end
|
||||
displayedChars[v] = true
|
||||
end
|
||||
return descObj
|
||||
end
|
||||
local function CoopDifferentEffectConditions(_)
|
||||
return #EID.DifferentEffectPlayers > 0
|
||||
end
|
||||
EID:addDescriptionModifier("EID Different Effect Players", CoopDifferentEffectConditions, CoopDifferentEffectCallback)
|
||||
Reference in new issue
Block a user