From ebb69dd5893aca657b0b03280a1616427a7beb90 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 24 Apr 2025 13:43:57 -0400 Subject: [PATCH] Rituals are now taken from the belt and shown in th combat_ui and in the system::combat. They aren't used in combat calcs yet though. --- Makefile | 4 ++-- assets/rituals.json | 9 --------- combat_ui.cpp | 18 +++++++++++++----- levelmanager.cpp | 3 +++ rituals.cpp | 4 ++-- systems.cpp | 8 +++++++- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 60f7708..562ac6d 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ tracy_build: meson compile -j 10 -C builddir test: build - ./builddir/runtests "[rituals-belt]" + ./builddir/runtests run: build test powershell "cp ./builddir/zedcaster.exe ." @@ -41,7 +41,7 @@ clean: meson compile --clean -C builddir debug_test: build - gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe -e "[rituals-belt]" + gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe -e win_installer: powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" win_installer.ifp' diff --git a/assets/rituals.json b/assets/rituals.json index f5a0396..6b358de 100644 --- a/assets/rituals.json +++ b/assets/rituals.json @@ -145,7 +145,6 @@ "pierce_type": { "damage": 11, "kind": 1, - "element": 0, "probability": 1.0 }, "magick_type": { @@ -156,26 +155,18 @@ }, "heals_user": { "damage": 13, - "kind": 0, - "element": 0, "probability": 1.0 }, "curses_user": { "damage": 14, - "kind": 0, - "element": 0, "probability": 0.5 }, "boost_damage_large": { "damage": 15, - "kind": 0, - "element": 0, "probability": 1.0 }, "combined": { "damage": 16, - "kind": 0, - "element": 0, "probability": 1.0 } } diff --git a/combat_ui.cpp b/combat_ui.cpp index e052218..b769304 100644 --- a/combat_ui.cpp +++ b/combat_ui.cpp @@ -1,6 +1,8 @@ #include "combat_ui.hpp" #include "constants.hpp" #include "color.hpp" +#include "rituals.hpp" +#include namespace gui { using namespace guecs; @@ -10,7 +12,7 @@ namespace gui { { $gui.position(COMBAT_UI_X, COMBAT_UI_Y, COMBAT_UI_WIDTH, COMBAT_UI_HEIGHT); $gui.layout( - "[*%(100,150)button_attack | *%(100,150)button_block | *%(100,150)button_evade | *%(100,150)button_heal]"); + "[*%(100,150)button_0 | *%(100,150)button_1 | *%(100,150)button_2 | *%(100,150)button_3]"); } void CombatUI::make_button(std::string name, std::wstring label, Events::GUI event, int action) { @@ -26,10 +28,16 @@ namespace gui { void CombatUI::init() { $gui.world().set_the({$gui.$parser, ColorValue::DARK_MID}); - make_button("button_attack", L"Attack", Events::GUI::ATTACK, 1); - make_button("button_block", L"Block", Events::GUI::ATTACK, 2); - make_button("button_evade", L"Evade", Events::GUI::EVADE, 0); - make_button("button_heal", L"Heal", Events::GUI::HEAL, 0); + auto& the_belt = $level.world->get($level.player); + + for(int slot = 0; slot < 4; slot++) { + if(the_belt.has(slot)) { + std::string name = fmt::format("button_{}", slot); + std::wstring label = fmt::format(L"Attack {}", slot+1); + make_button(name, label, Events::GUI::ATTACK, slot); + } + } + $gui.init(); } diff --git a/levelmanager.cpp b/levelmanager.cpp index d4e1a9d..4bc59f3 100644 --- a/levelmanager.cpp +++ b/levelmanager.cpp @@ -38,6 +38,9 @@ void LevelManager::temp_create_player_rituals() { re.set_state(blanket, "has_spikes", true); re.plan(blanket); ritual = re.finalize(blanket); + dbc::check(ritual.kind == combat::RitualKind::PHYSICAL, + fmt::format("second attack is not physical but is {}", + int(ritual.kind))); the_belt.equip(1, ritual); } diff --git a/rituals.cpp b/rituals.cpp index 9caec8f..c93390b 100644 --- a/rituals.cpp +++ b/rituals.cpp @@ -95,8 +95,8 @@ namespace combat { auto& effect = effects[action.name]; result.damage += int(effect["damage"]); result.probability *= float(effect["probability"]); - result.kind = RitualKind(int(effect["kind"])); - result.element = RitualElement(int(effect["element"])); + if(effect.contains("kind")) result.kind = RitualKind(int(effect["kind"])); + if(effect.contains("element")) result.element = RitualElement(int(effect["element"])); } } diff --git a/systems.cpp b/systems.cpp index 12e9c4c..82989c4 100644 --- a/systems.cpp +++ b/systems.cpp @@ -208,7 +208,12 @@ void System::combat(GameLevel &level, int attack_id) { auto &collider = *level.collision; auto &world = *level.world; auto player = world.get_the(); + auto& the_belt = world.get(player.entity); + dbc::check(the_belt.has(attack_id), + fmt::format("the_belt does not have an attack with id={}", attack_id)); + + auto& ritual = the_belt.get(attack_id); const auto& player_position = world.get(player.entity); auto& player_combat = world.get(player.entity); @@ -238,7 +243,8 @@ void System::combat(GameLevel &level, int attack_id) { }; if(result.player_did > 0) { - auto effect = shaders::get(attack_id == 1 ? "flame" : "lightning"); + auto effect = shaders::get( + ritual.kind == combat::RitualKind::PHYSICAL ? "flame" : "lightning"); world.set(enemy.entity, {100, effect}); }