aboutsummaryrefslogtreecommitdiff
path: root/plugins/sword
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-06-14 10:30:45 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-06-14 10:30:45 +0200
commit3432efe82387a6a4145d087c4af1a354d4063901 (patch)
treeb71ead102d6b208b15307e3e4fcf82489362cd1c /plugins/sword
parentce54c5dec3236d74e39b6364b9aa860a42984575 (diff)
downloaddungeon_game-3432efe82387a6a4145d087c4af1a354d4063901.tar.xz
Add charged hits
Diffstat (limited to 'plugins/sword')
-rw-r--r--plugins/sword/Makefile2
-rw-r--r--plugins/sword/dependencies.txt1
-rw-r--r--plugins/sword/sword.c6
3 files changed, 8 insertions, 1 deletions
diff --git a/plugins/sword/Makefile b/plugins/sword/Makefile
index ee28952..034ba74 100644
--- a/plugins/sword/Makefile
+++ b/plugins/sword/Makefile
@@ -1,4 +1,4 @@
-plugins/sword/sword.so: plugins/sword/sword.c plugins/game/game.h plugins/movement/movement.h plugins/inventory/inventory.h
+plugins/sword/sword.so: plugins/sword/sword.c plugins/game/game.h plugins/movement/movement.h plugins/inventory/inventory.h plugins/recharge/recharge.h
cc -g -shared -fpic -o plugins/sword/sword.so plugins/sword/sword.c
PLUGINS := ${PLUGINS} plugins/sword/sword.so
diff --git a/plugins/sword/dependencies.txt b/plugins/sword/dependencies.txt
index b19003b..ad140f4 100644
--- a/plugins/sword/dependencies.txt
+++ b/plugins/sword/dependencies.txt
@@ -1,3 +1,4 @@
game
movement
inventory
+recharge
diff --git a/plugins/sword/sword.c b/plugins/sword/sword.c
index f399150..653692f 100644
--- a/plugins/sword/sword.c
+++ b/plugins/sword/sword.c
@@ -3,6 +3,7 @@
#include "../game/game.h"
#include "../movement/movement.h"
#include "../inventory/inventory.h"
+#include "../recharge/recharge.h"
static bool use_broken_sword(struct itemstack *stack)
{
@@ -22,6 +23,9 @@ static struct item broken_sword = {
static bool use_sword(struct itemstack *stack)
{
+ if (! is_charged())
+ return false;
+
int x, y;
x = player.x;
y = player.y;
@@ -35,6 +39,8 @@ static bool use_sword(struct itemstack *stack)
if (rand() % 100 == 0)
stack->item = &broken_sword;
+
+ recharge(1.0, "⚔ ");
}
return false;