diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-14 11:25:23 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-14 11:25:23 +0200 |
commit | bb0b5c95d7b1e89621e7ccd68bd9efccc4bd8134 (patch) | |
tree | c869088b7e3ca21e63df1d9d0063a30a11adf20f /plugins | |
parent | eaa7e66f3c11ecbe01f28dbc2b32271f4229438b (diff) | |
download | dungeon_game-bb0b5c95d7b1e89621e7ccd68bd9efccc4bd8134.tar.xz |
Add sword attack key
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sword/sword.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/plugins/sword/sword.c b/plugins/sword/sword.c index 653692f..dc1118d 100644 --- a/plugins/sword/sword.c +++ b/plugins/sword/sword.c @@ -55,6 +55,14 @@ static struct item sword = { .on_create = NULL, }; +static void handle_e() +{ + struct itemstack *stack = inventory_find(&player_inventory, &sword); + + if (stack) + use_sword(stack); +} + __attribute__((constructor)) static void init() { inventory_add(&player_inventory, (struct itemstack) { @@ -62,4 +70,9 @@ __attribute__((constructor)) static void init() .count = 1, .meta = NULL, }); + + register_input_handler('e', (struct input_handler) { + .run_if_dead = false, + .callback = &handle_e, + }); } |