Skip to content

Commit

Permalink
port to h2m
Browse files Browse the repository at this point in the history
  • Loading branch information
PonyWarrior committed Jun 6, 2024
1 parent a132d20 commit 8f7882d
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 64 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Ported to Hell 2 Modding format

### Fixed

- Fixed altar menu opening twice with PonyAO installed

## [0.3.6] - 2024-06-05

### Fixed
Expand Down
38 changes: 0 additions & 38 deletions src/Data/Game/Text/TraitText.en.sjson

This file was deleted.

14 changes: 9 additions & 5 deletions src/Data/TraitData_Keepsake.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not PonyAltar.Config.Enabled then return end

TraitSetData.Keepsakes = {
Keepsakes = {
BaseBoonUpgradeKeepsake =
{
InheritFrom = { "GiftTrait" },
Expand All @@ -25,6 +23,7 @@ TraitSetData.Keepsakes = {
}
},
AltarBoon = {
Name = "AltarBoon",
InheritFrom = { "BaseBoonUpgradeKeepsake" },
Icon = "GUI\\Screens\\Codex\\Icon-Unseen",
Slot = "Altar",
Expand Down Expand Up @@ -619,5 +618,10 @@ TraitSetData.Keepsakes = {
},
}


OverwriteTableKeys(TraitData, TraitSetData.Keepsakes)
for key, keepsake in pairs(Keepsakes) do
if TraitData[key] then
OverwriteTableKeys(TraitData[key], keepsake)
else
TraitData[key] = keepsake
end
end
6 changes: 2 additions & 4 deletions src/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local config = {
Enabled = true,
return {
enabled = true,
}
PonyAltar.Config = config
return config
12 changes: 12 additions & 0 deletions src/def.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---@meta AuthorName-ModName
local public = {}

-- document whatever you made publicly available to other plugins here
-- use luaCATS annotations and give descriptions where appropriate
-- e.g.
-- ---@param a integer helpful description
-- ---@param b string helpful description
-- ---@return table c helpful description
-- function public.do_stuff(a, b) end

return public
63 changes: 62 additions & 1 deletion src/main.lua
Original file line number Diff line number Diff line change
@@ -1 +1,62 @@
rom.mods['SGG_Modding-DemonDaemon'].auto()
---@meta _
-- grabbing our dependencies,
-- these funky (---@) comments are just there
-- to help VS Code find the definitions of things

---@diagnostic disable-next-line: undefined-global
local mods = rom.mods

---@module 'SGG_Modding-ENVY-auto'
mods['SGG_Modding-ENVY'].auto()
-- ^ this gives us `public` and `import`, among others
-- and makes all globals we define private to this plugin.
---@diagnostic disable: lowercase-global

---@diagnostic disable-next-line: undefined-global
rom = rom
---@diagnostic disable-next-line: undefined-global
_PLUGIN = _PLUGIN

-- get definitions for the game's globals
---@module 'game'
game = rom.game
---@module 'game-import'
import_as_fallback(game)

---@module 'SGG_Modding-SJSON'
sjson = mods['SGG_Modding-SJSON']
---@module 'SGG_Modding-ModUtil'
modutil = mods['SGG_Modding-ModUtil']

---@module 'SGG_Modding-Chalk'
chalk = mods["SGG_Modding-Chalk"]
---@module 'SGG_Modding-ReLoad'
reload = mods['SGG_Modding-ReLoad']

---@module 'config'
config = chalk.auto 'config.lua'
-- ^ this updates our `.cfg` file in the config folder!
public.config = config -- so other mods can access our config

local function on_ready()
-- what to do when we are ready, but not re-do on reload.
if config.enabled == false then return end

import 'ready.lua'
import 'Data/TraitData_Keepsake.lua'
end

local function on_reload()
-- what to do when we are ready, but also again on every reload.
-- only do things that are safe to run over and over.

import 'reload.lua'
end

-- this allows us to limit certain functions to not be reloaded.
local loader = reload.auto_single()

-- this runs only when modutil and the game's lua is ready
modutil.once_loaded.game(function()
loader.load(on_ready, on_reload)
end)
9 changes: 0 additions & 9 deletions src/modfile.txt

This file was deleted.

53 changes: 47 additions & 6 deletions src/core.lua → src/ready.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,52 @@
local mod = PonyAltar
---@meta _
-- globals we define are private to our plugin!
---@diagnostic disable: lowercase-global

if not mod.Config.Enabled then return end
-- here is where your mod sets up all the things it will do.
-- this file will not be reloaded if it changes during gameplay
-- so you will most likely want to have it reference
-- values and functions later defined in `reload.lua`.

mod = modutil.mod.Mod.Register(_PLUGIN.guid)

local textfile = rom.path.combine(rom.paths.Content, 'Game/Text/en/TraitText.en.sjson')

local ids_to_descriptions = {
ForceZeusBoonKeepsake = "While you have {$Keywords.ReserveMana} Magick{!Icons.Mana}, your {$Keywords.Omega} use {#ManaFormat}{$TooltipData.ExtractData.ManaDelta:F} {#Prev}less Magick{!Icons.Mana}.",
ForceZeusBoonKeepsake_Inactive = "While you have {$Keywords.ReserveMana} Magick{!Icons.Mana}, your {$Keywords.Omega} use {#ManaFormat}{$TooltipData.ExtractData.ManaDelta:F} {#Prev}less Magick{!Icons.Mana}.",

ForcePoseidonBoonKeepsake = "Slain enemies drop {#MoneyFormatBold}+{$TooltipData.ExtractData.TooltipHeal:F} {!Icons.Currency}{#Prev}.",
ForcePoseidonBoonKeepsake_Inactive = "Slain enemies drop {#MoneyFormatBold}+{$TooltipData.ExtractData.TooltipHeal:F} {!Icons.Currency}{#Prev}.",

ForceApolloBoonKeepsake = "Extends the invulnerability period of your {$Keywords.Dash} by {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipMultiplier:F}{#Prev}.",
ForceApolloBoonKeepsake_Inactive = "Extends the invulnerability period of your {$Keywords.Dash} by {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipMultiplier:F}{#Prev}.",

ForceHestiaBoonKeepsake = "All your damage is increased by {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipDamage:F} {#Prev}, but you have {#PenaltyFormat}{$TooltipData.ExtractData.HealthPenalty:P}{#Prev}{!Icons.HealthDown}.",
ForceHestiaBoonKeepsake_Inactive = "All your damage is increased by {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipDamage:F} {#Prev}, but you have {#PenaltyFormat}{$TooltipData.ExtractData.HealthPenalty:P}{#Prev}{!Icons.HealthDown}.",

ForceHephaestusBoonKeepsake = "You gain {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipArmor:F} {#Prev} of all {!Icons.HealthUp} rewards as {!Icons.ArmorTotal}.",
ForceHephaestusBoonKeepsake_Inactive = "You gain {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipArmor:F} {#Prev} of all {!Icons.HealthUp} rewards as {!Icons.ArmorTotal}.",

ForceAphroditeBoonKeepsake = "Increases your chances to receive a {$Keywords.GodBoon} of higher {$Keywords.Rarity}. {#RareFormat}Rare {#Prev}{#AltUpgradeFormat}{$TooltipData.ExtractData.RareBonus:P} {#Prev}, {#EpicFormat}Epic {#Prev}{#AltUpgradeFormat}{$TooltipData.ExtractData.EpicBonus:P} {#Prev}and {#DuoFormat}Duo {#Prev}{#AltUpgradeFormat}{$TooltipData.ExtractData.DuoBonus:P} {#Prev}.",
ForceAphroditeBoonKeepsake_Inactive = "Increases your chances to receive a {$Keywords.GodBoon} of higher {$Keywords.Rarity}. {#RareFormat}Rare {#Prev}{#AltUpgradeFormat}{$TooltipData.ExtractData.RareBonus:P} {#Prev}, {#EpicFormat}Epic {#Prev}{#AltUpgradeFormat}{$TooltipData.ExtractData.EpicBonus:P} {#Prev}and {#DuoFormat}Duo {#Prev}{#AltUpgradeFormat}{$TooltipData.ExtractData.DuoBonus:P} {#Prev}.",

ForceDemeterBoonKeepsake = "While under {#BoldFormatGraft}{$TooltipData.ExtractData.Health:F}{#Prev}{!Icons.Health}, your {$Keywords.Omega} use {#ManaFormat}{$TooltipData.ExtractData.ManaDelta:F} {#Prev}less Magick{!Icons.Mana}.",
ForceDemeterBoonKeepsake_Inactive = "While under {#BoldFormatGraft}{$TooltipData.ExtractData.Health:F}{#Prev}{!Icons.Health}, your {$Keywords.Omega} use {#ManaFormat}{$TooltipData.ExtractData.ManaDelta:F} {#Prev}less Magick{!Icons.Mana}.",

ForceHeraBoonKeepsake = "Your {$Keywords.Attack} and {$Keywords.Special} each deal {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipBonus:P} {#Prev}damage while not empowered by a {$Keywords.GodBoon}.",
ForceHeraBoonKeepsake_Inactive = "Your {$Keywords.Attack} and {$Keywords.Special} each deal {#AltUpgradeFormat}{$TooltipData.ExtractData.TooltipBonus:P} {#Prev}damage while not empowered by a {$Keywords.GodBoon}.",
}

sjson.hook(textfile, function(sjsonData)
for _, v in ipairs(sjsonData.Texts) do
local description = ids_to_descriptions[v.Id]
if description then v.Description = description end
end
end)

table.insert(HubRoomData.Hub_PreRun.StartUnthreadedEvents,
{
FunctionName = "PonyAltar.SpawnAltar"
FunctionName = _PLUGIN.guid .. '.' .. 'SpawnAltar'
})

ModUtil.Table.Merge(ScreenData, {
Expand Down Expand Up @@ -78,7 +120,7 @@ ModUtil.Table.Merge(ScreenData, {
OffsetY = ScreenCenterY - 70,
Data =
{
OnPressedFunctionName = "PonyAltar.ClosePonyAltar",
OnPressedFunctionName = _PLUGIN.guid .. '.' .. 'ClosePonyAltar',
ControlHotkeys = { "Cancel", },
},
},
Expand All @@ -101,7 +143,7 @@ function mod.SpawnAltar()
-- Card altar
local spawnId = 589766
local altar = DeepCopyTable(ObstacleData.GiftRack)
altar.OnUsedFunctionName = "PonyAltar.OpenAltarMenu"
altar.OnUsedFunctionName = _PLUGIN.guid .. '.' .. 'OpenAltarMenu'
altar.ObjectId = SpawnObstacle({
Name = "GiftRack",
Group = "FX_Terrain",
Expand Down Expand Up @@ -452,6 +494,5 @@ end)

ModUtil.Path.Wrap("KeepsakeScreenClose", function(base, ...)
base(...)
-- rom.data.reload_game_data()
mod.OpenAltarMenu()
end)
1 change: 0 additions & 1 deletion src/register.lua

This file was deleted.

7 changes: 7 additions & 0 deletions src/reload.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---@meta _
-- globals we define are private to our plugin!
---@diagnostic disable: lowercase-global

-- this file will be reloaded if it changes during gameplay,
-- so only assign to values or define things here.

0 comments on commit 8f7882d

Please sign in to comment.