3 #include "../game/game.h"
4 #include "../movement/movement.h"
5 #include "../inventory/inventory.h"
6 #include "../recharge/recharge.h"
8 static bool use_broken_sword(struct itemstack *stack)
15 static struct item broken_sword = {
16 .name = "Broken Sword",
19 .on_use = &use_broken_sword,
24 static bool use_sword(struct itemstack *stack)
33 dir_to_xy(last_player_move, &x, &y);
35 struct entity *entity = entity_collision_map[x][y];
38 add_health(entity, -1);
40 if (rand() % 100 == 0)
41 stack->item = &broken_sword;
49 static struct item sword = {
58 static void handle_e()
60 struct itemstack *stack = inventory_find(&player_inventory, &sword);
66 __attribute__((constructor)) static void init()
68 inventory_add(&player_inventory, (struct itemstack) {
74 register_input_handler('e', (struct input_handler) {
76 .callback = &handle_e,