diff --git a/include/setup.h b/include/setup.h
index 928a468..5c1800e 100644
--- a/include/setup.h
+++ b/include/setup.h
@@ -64,9 +64,13 @@ void enemy_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy);
void load_attacks(gc_scene *scene);
+void mia_setup(gc_engine *engine);
bool mia_heal(gc_engine *engine, gc_entity *entity, \
gc_vector2 pos, enum gc_mousekeys key);
-void mia_setup(gc_engine *engine);
+bool mia_save(gc_engine *engine, gc_entity *entity, \
+gc_vector2 pos, enum gc_mousekeys key);
+bool mia_fish(gc_engine *engine, gc_entity *entity, \
+gc_vector2 pos, enum gc_mousekeys key);
- void load_data(gc_scene *scene, const gc_data *datas);
+void load_data(gc_scene *scene, const gc_data *datas);
extern const struct gc_data game_data[];
\ No newline at end of file
diff --git a/include/systems/game_manager_system.h b/include/systems/game_manager_system.h
index 2a52370..0197068 100644
--- a/include/systems/game_manager_system.h
+++ b/include/systems/game_manager_system.h
@@ -13,6 +13,7 @@
struct game_manager_system {
gc_system base;
bool is_inventory;
+ bool has_message;
};
const struct game_manager_system game_manager_system;
diff --git a/prefabs/game.gcprefab b/prefabs/game.gcprefab
index 88da4d6..8bee568 100644
--- a/prefabs/game.gcprefab
+++ b/prefabs/game.gcprefab
@@ -225,7 +225,7 @@
-
+
diff --git a/src/components/dialog_holder.c b/src/components/dialog_holder.c
index 0c9e92b..48ec71c 100644
--- a/src/components/dialog_holder.c
+++ b/src/components/dialog_holder.c
@@ -66,7 +66,10 @@ bool dialog_parse_inputs(struct dialog_line *txt, gc_scene *scene, node *n)
for (n = n->child; n; n = n->next) {
txt->inputs[i].text = xml_getproperty(n, "text");
click = xml_gettempprop(n, "click");
- txt->inputs[i].callback = scene->get_data(scene, "input", click);
+ if (click)
+ txt->inputs[i].callback = scene->get_data(scene, "input", click);
+ else
+ txt->inputs[i].callback = NULL;
if (!txt->inputs[i++].callback && click)
my_printf("Couldn't find an input with the name: %s.\n", click);
}
diff --git a/src/game_loader.c b/src/game_loader.c
index 92b1722..05425e6 100644
--- a/src/game_loader.c
+++ b/src/game_loader.c
@@ -53,6 +53,8 @@ const struct callback callbacks[] = {
const struct gc_data game_data[] = {
{"input", "mia_heal", &mia_heal, NULL},
+ {"input", "mia_save", &mia_save, NULL},
+ {"input", "mia_fish", &mia_fish, NULL},
{"dialog_callback", "mia_setup", &mia_setup, NULL},
{NULL, NULL, NULL, NULL}
};
diff --git a/src/npc/mia.c b/src/npc/mia.c
index e570472..d8b2233 100644
--- a/src/npc/mia.c
+++ b/src/npc/mia.c
@@ -1,12 +1,13 @@
/*
** EPITECH PROJECT, 2020
-** my_rpg
+** my_rpg
** File description:
** mia.c
*/
#include
#include
+#include
#include "engine.h"
struct dialog_holder *dialog_get_current(gc_engine *engine)
@@ -46,4 +47,37 @@ any wounds.", NULL);
here for that?", NULL);
}
return (true);
-}
\ No newline at end of file
+}
+
+bool mia_save(gc_engine *engine, gc_entity *entity, \
+gc_vector2 pos, enum gc_mousekeys key)
+{
+ struct dialog_holder *dialog = dialog_get_current(engine);
+
+ if (!dialog)
+ return (false);
+ dialog_add_line(dialog, "Mia", "Save the GAME?\n\
+What are you talking about?", NULL);
+ dialog_add_line(dialog, "Mia", "Do you think this is a game?", NULL);
+ dialog_add_line(dialog, "Mia", "We are dying for real here.\n\
+Go cure the village NOW.", NULL);
+ return (true);
+}
+
+bool mia_fish(gc_engine *engine, gc_entity *entity, \
+gc_vector2 pos, enum gc_mousekeys key)
+{
+ struct dialog_holder *dialog = dialog_get_current(engine);
+
+ if (!dialog)
+ return (false);
+ if (!GETSYS(engine, game_manager_system)->has_message) {
+ dialog_add_line(dialog, "", "You don't have any message\n\
+to give to Mia", NULL);
+ return (true);
+ }
+ dialog_add_line(dialog, "Mia", "The fisherman?\n\
+Oh so he will come for dinner.", NULL);
+ dialog_add_line(dialog, "Mia", "Than you for telling me!", NULL);
+ return (true);
+}
diff --git a/src/systems/game_manager_system.c b/src/systems/game_manager_system.c
index ce28077..00a0cb8 100644
--- a/src/systems/game_manager_system.c
+++ b/src/systems/game_manager_system.c
@@ -51,9 +51,11 @@ float dtime)
static void ctr(void *system, va_list list)
{
gc_engine *engine = va_arg(list, gc_engine *);
-
+ struct game_manager_system *this = system;
engine->add_event_listener(engine, "key_pressed", &key_pressed);
+ this->has_message = false;
+ this->is_inventory = false;
}
static void dtr(void *system, gc_engine *engine)
@@ -63,7 +65,7 @@ static void dtr(void *system, gc_engine *engine)
const struct game_manager_system game_manager_system = {
base : {
- name: "game_cycle",
+ name: "game_manager_system",
component_name: "game_manager",
size: sizeof(struct game_manager_system),
ctr: &ctr,