diff --git a/Makefile b/Makefile index a05ee9b..a51847b 100644 --- a/Makefile +++ b/Makefile @@ -230,7 +230,8 @@ SRC_NPC_UPDATE := update_dialog_text.c \ update_intro_magician.c \ update_dialogue_box.c \ update_npc.c \ - update_elder.c + update_elder.c \ + event_skip_tp_magi.c SRC_NPC_UPDATE := $(addprefix update/,$(SRC_NPC_UPDATE)) SRC_CHEST := dropping_infinity_86.c \ diff --git a/assets/data/npc/rotation_data.json b/assets/data/npc/rotation_data.json index 25a46a6..2abe21e 100644 --- a/assets/data/npc/rotation_data.json +++ b/assets/data/npc/rotation_data.json @@ -1,5 +1,5 @@ { - "total time": 3.0, + "total time": 9.0, "actualisation time": 0.01, "rotation": 5.0, "zoom": 40.0 diff --git a/include/npc.h b/include/npc.h index cbd0e93..1fb0814 100644 --- a/include/npc.h +++ b/include/npc.h @@ -107,9 +107,11 @@ void update_magician(object_t *obj, scene_t *scene, window_t *win, void init_npc_spawner(object_t *obj, scene_t *scene, window_t *win, __attribute__((unused)) float time); -void event_quit_dialog_off(__attribute__((unused)) object_t *obj, - scene_t *scene, window_t *win, - __attribute__((unused)) set_event_t *event); +void event_quit_dialog_off(object_t *obj, scene_t *scene, window_t *win, + set_event_t *event); + +void skip_event_magician_tp(object_t *obj, scene_t *scene, window_t *win, + set_event_t *evt); void update_end_magician(object_t *obj, scene_t *scene, window_t *win, float dtime); diff --git a/src/npc/update/event_skip_tp_magi.c b/src/npc/update/event_skip_tp_magi.c new file mode 100644 index 0000000..1d537ba --- /dev/null +++ b/src/npc/update/event_skip_tp_magi.c @@ -0,0 +1,34 @@ +/* +** EPITECH PROJECT, 2022 +** myrpg +** File description: +** event to skip tp +*/ + +#include "my_bgs.h" +#include "my_bgs_framebuffer.h" +#include "my_json.h" +#include "npc.h" + +extern const char rotation_data_key[]; + +extern const char total_time_key[]; + +void skip_event_magician_tp(object_t *obj, + __attribute__((unused)) scene_t *scene, + __attribute__ ((unused)) window_t *win, + __attribute__((unused)) set_event_t *evt) +{ + any_t *rotation_data = NULL; + any_t *total_time = NULL; + + if (obj == NULL) { + return; + } + rotation_data = dico_t_get_value(obj->components, rotation_data_key); + total_time = get_from_any(rotation_data, "d", total_time_key); + if (total_time == NULL) { + return; + } + total_time->value.f = 0; +} diff --git a/src/npc/update/magician_view_rotation.c b/src/npc/update/magician_view_rotation.c index 52d8ef5..e8cc483 100644 --- a/src/npc/update/magician_view_rotation.c +++ b/src/npc/update/magician_view_rotation.c @@ -5,20 +5,22 @@ ** magician view rotation */ +#include +#include #include "my_bgs.h" +#include "my_bgs_components.h" #include "my_dico.h" #include "npc.h" #include "macro.h" #include "rpg_struct.h" #include "stage.h" #include "player.h" -#include static const char view_rotation_data[] = "./assets/data/npc/rotation_data.json"; -static const char rotation_data_key[] = "rotation data"; +const char rotation_data_key[] = "rotation data"; -static const char total_time_key[] = "total time"; +const char total_time_key[] = "total time"; static const char actualisation_time_key[] = "actualisation time"; @@ -117,6 +119,8 @@ void create_view_rotation(scene_t *scene) if (object_set_custom(obj) != BGS_OK) { return; } + event_add_node(create_event(skip_event_magician_tp, false, obj, NULL), + (node_params_t) {sfMouseLeft, sfKeyReturn, KEY}); rotation_data = parse_json_file(view_rotation_data); if (rotation_data == NULL || rotation_data->type != DICT) { return;