3 #include "../game/game.h"
4 #include "../movement/movement.h"
5 #include "../inventory/inventory.h"
6 #include "../recharge/recharge.h"
7 #include "../loot/loot.h"
9 static bool use_broken_sword(struct itemstack *stack)
14 static struct item broken_sword = {
15 .name = "Broken Sword",
18 .on_use = &use_broken_sword,
23 static bool use_sword(struct itemstack *stack)
32 dir_to_xy(last_player_move, &x, &y);
34 struct entity *entity = entity_collision_map[x][y];
37 add_health(entity, -1);
39 if (rand() % 100 == 0)
40 stack->item = &broken_sword;
48 static struct item sword = {
57 static void handle_e()
59 struct itemstack *stack = inventory_find(&player_inventory, &sword);
65 __attribute__((constructor)) static void init()
67 inventory_add(&player_inventory, (struct itemstack) {
73 register_input_handler('e', (struct input_handler) {
75 .callback = &handle_e,
78 register_loot((struct loot) {