Skip to content

Commit

Permalink
Merge pull request #186 from X-R-G-B/cancel-tp-magician
Browse files Browse the repository at this point in the history
Cancel tp magician
  • Loading branch information
romainpanno authored May 8, 2022
2 parents dcfe4ef + a64e416 commit 7933df0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion assets/data/npc/rotation_data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"total time": 3.0,
"total time": 9.0,
"actualisation time": 0.01,
"rotation": 5.0,
"zoom": 40.0
Expand Down
8 changes: 5 additions & 3 deletions include/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 34 additions & 0 deletions src/npc/update/event_skip_tp_magi.c
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 7 additions & 3 deletions src/npc/update/magician_view_rotation.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
** magician view rotation
*/

#include <SFML/Window/Keyboard.h>
#include <stdbool.h>
#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 <stdbool.h>

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";

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7933df0

Please sign in to comment.