2023-06-06 18:08:11 +02:00
|
|
|
local modname = "DeadGod Helper"
|
|
|
|
local mod = RegisterMod(modname, 1)
|
|
|
|
local math = require("math")
|
|
|
|
mod.print = Isaac.ConsoleOutput
|
|
|
|
mod.game = Game()
|
|
|
|
local save = include("save"):new()
|
2023-06-07 18:20:33 +02:00
|
|
|
local DEBUG = false
|
2023-06-06 18:08:11 +02:00
|
|
|
|
|
|
|
mod.font = Font()
|
|
|
|
mod.font:Load("font/terminus.fnt")
|
|
|
|
|
|
|
|
function mod:isCurseBlind()
|
|
|
|
return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function mod.isIdNotTakenAlready(id)
|
|
|
|
if id>=1 and id<=save.settings.maxid then
|
|
|
|
return not save.seen[id]
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function mod.registerTouched(id)
|
|
|
|
if id>=1 and id<=save.settings.maxid then
|
|
|
|
save.seen[id] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Save
|
2023-06-07 17:09:59 +02:00
|
|
|
mod:RemoveData()
|
|
|
|
mod:SaveData(save:dump())
|
2023-06-06 18:08:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Used to check if EID's description should be modified
|
|
|
|
function mod.shouldBeModified(descObj)
|
|
|
|
-- Taken from https://github.com/wofsauge/External-Item-Descriptions/wiki/Description-Modifiers
|
|
|
|
-- if entity is a piedestal
|
|
|
|
if descObj.ObjType == 5 and descObj.ObjVariant == 100 then
|
|
|
|
-- Check if item was not already taken in this savefile
|
|
|
|
-- And if item is non-modded (id<= Mom's ring ID)
|
|
|
|
local id = descObj.ObjSubType
|
|
|
|
return mod.isIdNotTakenAlready(id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Used to modify EID's description
|
|
|
|
function mod.modifierCallback(descObj)
|
|
|
|
if save.settings.eid then
|
|
|
|
descObj.Description = "#{{Trophy}} Not picked up yet!#"..descObj.Description
|
|
|
|
end
|
|
|
|
return descObj
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Used to detect when an item is picked up
|
|
|
|
function mod:update()
|
|
|
|
for i=0, mod.game:GetNumPlayers()-1 do
|
|
|
|
local player = mod.game:GetPlayer(i)
|
|
|
|
local data = player:GetData()
|
|
|
|
local item = player.QueuedItem.Item
|
|
|
|
if data._deadgodlastid and data._deadgodlastcount and data._deadgodlastid>0 then
|
|
|
|
if item==nil then -- Finished animation
|
|
|
|
if player:GetCollectibleNum(data._deadgodlastid)>data._deadgodlastcount then -- Have it on me
|
|
|
|
-- Then I just picked it up, yay
|
|
|
|
mod.registerTouched(data._deadgodlastid)
|
2023-06-07 18:20:33 +02:00
|
|
|
if DEBUG then
|
|
|
|
mod.print("> "..tostring(data._deadgodlastid).."\n")
|
|
|
|
end
|
2023-06-06 18:08:11 +02:00
|
|
|
data._deadgodlastid = 0
|
|
|
|
data._deadgodlastcount = 0
|
2023-06-07 17:09:59 +02:00
|
|
|
end end
|
2023-06-06 18:08:11 +02:00
|
|
|
end
|
|
|
|
if item and item:IsCollectible() then
|
|
|
|
data._deadgodlastid = item.ID
|
|
|
|
data._deadgodlastcount = player:GetCollectibleNum(item.ID)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Used to draw the ! sign
|
|
|
|
function mod:PickupDrawCallback(pickupEntity, _)
|
|
|
|
if save.settings.visual and (not mod:isCurseBlind() or save.settings.showonblind)then
|
|
|
|
if pickupEntity.Variant==PickupVariant.PICKUP_COLLECTIBLE then
|
|
|
|
if mod.isIdNotTakenAlready(pickupEntity.SubType) then
|
|
|
|
local v = Isaac.WorldToScreen(pickupEntity.Position + pickupEntity.SpriteOffset)
|
|
|
|
mod.font:DrawString("!", v.X-1, v.Y-52+math.sin(mod.game:GetFrameCount()/10)*2, KColor(0.98,0.93,0.55,1), 2, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-06-07 17:38:40 +02:00
|
|
|
function mod:newrun()
|
|
|
|
if mod:HasData() then
|
|
|
|
local data = mod:LoadData()
|
2023-06-07 18:20:33 +02:00
|
|
|
if DEBUG then
|
|
|
|
mod.print(data.."\n")
|
|
|
|
end
|
2023-06-07 17:38:40 +02:00
|
|
|
save:load(data)
|
|
|
|
local c = 0
|
|
|
|
for _,v in ipairs(save.seen) do
|
|
|
|
if v then c = c+1 end
|
|
|
|
end
|
|
|
|
mod.print(modname.." Loaded, "..c.." items seen\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-06-07 17:09:59 +02:00
|
|
|
function mod:preGameExit()
|
|
|
|
mod:SaveData(save:dump())
|
|
|
|
end
|
|
|
|
|
2023-06-07 17:38:40 +02:00
|
|
|
mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.preGameExit)
|
|
|
|
mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.newrun)
|
2023-06-07 17:09:59 +02:00
|
|
|
|
2023-06-06 18:08:11 +02:00
|
|
|
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
|
|
|
|
mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.PickupDrawCallback)
|
|
|
|
|
|
|
|
if EID then
|
|
|
|
EID:addDescriptionModifier(
|
|
|
|
modname,
|
|
|
|
mod.shouldBeModified,
|
|
|
|
mod.modifierCallback
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
if ModConfigMenu then
|
|
|
|
ModConfigMenu.AddSetting(
|
|
|
|
modname, -- This should be unique for your mod
|
|
|
|
nil,
|
|
|
|
{
|
|
|
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
|
|
|
CurrentSetting = function()
|
|
|
|
return save.settings.eid
|
|
|
|
end,
|
|
|
|
Display = function()
|
|
|
|
return "Show in EID: " .. (save.settings.eid and "on" or "off")
|
|
|
|
end,
|
|
|
|
OnChange = function(b)
|
|
|
|
save.settings.eid = b
|
2023-06-07 17:38:40 +02:00
|
|
|
mod:SaveData(save:dump())
|
2023-06-06 18:08:11 +02:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
ModConfigMenu.AddSetting(
|
|
|
|
modname, -- This should be unique for your mod
|
|
|
|
nil,
|
|
|
|
{
|
|
|
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
|
|
|
CurrentSetting = function()
|
|
|
|
return save.settings.visual
|
|
|
|
end,
|
|
|
|
Display = function()
|
|
|
|
return "Show on pedestals: " .. (save.settings.visual and "on" or "off")
|
|
|
|
end,
|
|
|
|
OnChange = function(b)
|
|
|
|
save.settings.visual = b
|
2023-06-07 17:38:40 +02:00
|
|
|
mod:SaveData(save:dump())
|
2023-06-06 18:08:11 +02:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
ModConfigMenu.AddSetting(
|
|
|
|
modname, -- This should be unique for your mod
|
|
|
|
nil,
|
|
|
|
{
|
|
|
|
Type = ModConfigMenu.OptionType.BOOLEAN,
|
|
|
|
CurrentSetting = function()
|
|
|
|
return save.settings.showonblind
|
|
|
|
end,
|
|
|
|
Display = function()
|
|
|
|
return "Show while having Curse Of The Blind: " .. (save.settings.showonblind and "on" or "off")
|
|
|
|
end,
|
|
|
|
OnChange = function(b)
|
|
|
|
save.settings.showonblind = b
|
2023-06-07 17:38:40 +02:00
|
|
|
mod:SaveData(save:dump())
|
2023-06-06 18:08:11 +02:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|