From 29497d4a4175ffa403cfc226224945a47d2ebe58 Mon Sep 17 00:00:00 2001 From: Anonymus Raccoon Date: Wed, 29 Apr 2020 12:42:48 +0200 Subject: [PATCH] Removing a bug that stuck the player --- lib/gamacon | 2 +- src/combat/attacks.c | 2 +- src/systems/combat_manager.c | 3 +++ src/systems/dialog_methods.c | 11 ++++++----- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/gamacon b/lib/gamacon index 8493449..d1a8a90 160000 --- a/lib/gamacon +++ b/lib/gamacon @@ -1 +1 @@ -Subproject commit 8493449a020472127da0468bf1159c33aab0d5b7 +Subproject commit d1a8a904a4fe490745de6e2fd543cff1b9da1bc8 diff --git a/src/combat/attacks.c b/src/combat/attacks.c index 66d8bab..b3752c0 100644 --- a/src/combat/attacks.c +++ b/src/combat/attacks.c @@ -92,7 +92,7 @@ void enemy_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy) struct combat_manager *this = GETSYS(engine, combat_manager); struct health_component *enemy_health = GETCMP(enemy, health_component); struct renderer *rend = GETCMP(from, renderer); - int max = 20 - this->last_enemy_damage; + int max = 10 - this->last_enemy_damage; this->last_enemy_damage = MAX(MIN(random() % max, 10), 0); if (this->last_attack && !my_strcmp(this->last_attack, "shield")) diff --git a/src/systems/combat_manager.c b/src/systems/combat_manager.c index 95844c7..4a2e172 100644 --- a/src/systems/combat_manager.c +++ b/src/systems/combat_manager.c @@ -83,6 +83,9 @@ static void ctr(void *system, va_list list) this->game_scene = NULL; this->state = ATTACK; + this->last_enemy_damage = 0; + this->last_damage = 0; + this->last_attack = NULL; engine->add_event_listener(engine, "entity_moved", &entity_moved); } diff --git a/src/systems/dialog_methods.c b/src/systems/dialog_methods.c index 46fedf8..94d3121 100644 --- a/src/systems/dialog_methods.c +++ b/src/systems/dialog_methods.c @@ -16,7 +16,7 @@ #include "engine.h" #include "tile.h" -void load_dialog(struct dialog_manager *this, gc_engine *engine, \ +bool load_dialog(struct dialog_manager *this, gc_engine *engine, \ gc_entity *player) { struct map_linker *link = GETCMP(player, map_linker); @@ -26,7 +26,7 @@ gc_entity *player) if (!link || !link->tile || !link->tile->type || \ my_strcmp(link->tile->type, "dialog")) - return; + return (false); this->dialog_id = prefab_load(engine, "prefabs/dialog.gcprefab"); if (this->dialog_id < 0) my_printf("Couldn't load the dialog prefab.\n"); @@ -36,9 +36,10 @@ my_strcmp(link->tile->type, "dialog")) this->current_dialog = dialog; } if (!this->current_dialog) - return; + return (false); this->current_text = this->current_dialog->text[0]; this->current_line = 0; + return (true); } bool update_dialog(struct dialog_manager *this, gc_entity *text, \ @@ -109,8 +110,8 @@ void dialog_next(gc_engine *engine) if (!entity) return; - if (this->dialog_id == -1) - load_dialog(this, engine, entity); + if (this->dialog_id == -1 && !load_dialog(this, engine, entity)) + return; if (this->input_id >= 0) run_input_func(this, engine); controllable_set_can_move(scene, false);