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)
13 static struct item broken_sword = {
14 .name = "Broken Sword",
17 .on_use = &use_broken_sword,
22 static bool use_sword(struct itemstack *stack)
31 dir_to_xy(last_player_move, &x, &y);
33 struct entity *entity = entity_collision_map[x][y];
36 add_health(entity, -1);
38 if (rand() % 100 == 0)
39 stack->item = &broken_sword;
47 static struct item sword = {
56 static void handle_e()
58 struct itemstack *stack = inventory_find(&player_inventory, &sword);
64 __attribute__((constructor)) static void init()
66 inventory_add(&player_inventory, (struct itemstack) {
72 register_input_handler('e', (struct input_handler) {
74 .callback = &handle_e,