Simple battle system included in the boss fight but I need to figure out how it should operate.
This commit is contained in:
parent
d418f073f0
commit
8ee3e8736f
8 changed files with 75 additions and 17 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#include <fmt/core.h>
|
||||
#include "components.hpp"
|
||||
#include "game_level.hpp"
|
||||
#include "ai.hpp"
|
||||
#include "battle.hpp"
|
||||
|
||||
namespace boss {
|
||||
using namespace components;
|
||||
|
|
@ -10,6 +12,22 @@ namespace boss {
|
|||
fmt::println("load it");
|
||||
}
|
||||
|
||||
void System::initialize_boss_ai(DinkyECS::World& world, DinkyECS::Entity boss_id) {
|
||||
dbc::check(world.has<EnemyConfig>(boss_id), "boss doesn't have an AI EnemyConfig");
|
||||
|
||||
auto& config = world.get<EnemyConfig>(boss_id);
|
||||
|
||||
auto ai_start = ai::load_state(config.ai_start_name);
|
||||
|
||||
auto ai_goal = ai::load_state(config.ai_goal_name);
|
||||
|
||||
ai::EntityAI boss_ai(config.ai_script, ai_start, ai_goal);
|
||||
boss_ai.set_state("tough_personality", true);
|
||||
boss_ai.set_state("detect_enemy", true);
|
||||
|
||||
world.set<ai::EntityAI>(boss_id, boss_ai);
|
||||
}
|
||||
|
||||
shared_ptr<boss::Fight> System::create_bossfight() {
|
||||
auto& level = GameDB::current_level();
|
||||
auto prev_world = GameDB::current_world();
|
||||
|
|
@ -24,13 +42,52 @@ namespace boss {
|
|||
auto boss_id = world->entity();
|
||||
components::configure_entity(*world, boss_id, boss_data["components"]);
|
||||
|
||||
initialize_boss_ai(*world, boss_id);
|
||||
|
||||
dbc::check(world->has<ai::EntityAI>(boss_id), "boss doesn't have an AI");
|
||||
|
||||
return make_shared<boss::Fight>(world, boss_id);
|
||||
}
|
||||
|
||||
void System::combat(int attack_id) {
|
||||
(void)attack_id;
|
||||
}
|
||||
void System::combat(std::shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id, int attack_id) {
|
||||
// get the player from the previous level, but should I just make the boss fights a level?
|
||||
auto& level = GameDB::current_level();
|
||||
dbc::check(world->has<ai::EntityAI>(boss_id), "boss doesn't have an AI");
|
||||
|
||||
void System::ai_initialize() {
|
||||
auto& player_combat = world->get<Combat>(level.player);
|
||||
auto& boss_ai = world->get<ai::EntityAI>(boss_id);
|
||||
auto& boss_combat = world->get<Combat>(boss_id);
|
||||
|
||||
combat::BattleEngine battle;
|
||||
battle.add_enemy({boss_id, boss_ai, boss_combat});
|
||||
|
||||
battle.set_all("enemy_found", true);
|
||||
battle.set_all("in_combat", true);
|
||||
battle.plan();
|
||||
|
||||
battle.dump();
|
||||
|
||||
while(auto act = battle.next()) {
|
||||
auto [enemy, enemy_action] = *act;
|
||||
|
||||
Events::Combat result {
|
||||
player_combat.attack(enemy.combat), 0
|
||||
};
|
||||
|
||||
if(result.player_did > 0) {
|
||||
auto& the_belt = world->get_the<ritual::Belt>();
|
||||
|
||||
dbc::check(the_belt.has(attack_id), "STOP passing invalid attack IDs to the system.");
|
||||
fmt::println("player did damage");
|
||||
}
|
||||
|
||||
if(enemy_action == combat::BattleAction::ATTACK) {
|
||||
result.enemy_did = enemy.combat.attack(player_combat);
|
||||
fmt::println("enemy did damage");
|
||||
}
|
||||
|
||||
// need to replicate this in the boss UI
|
||||
world->send<Events::GUI>(Events::GUI::COMBAT, enemy.entity, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue