aboutsummaryrefslogtreecommitdiffstats
path: root/src/mob.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-06-29 17:56:48 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-06-29 17:56:48 -0400
commit3766c45c62eeca442e9ab700c09c547f08615b62 (patch)
tree37e2c5c2c28f7a0c79eb39daa6276e018595be18 /src/mob.cpp
parentdf12451f837854c816bed32ae0d962fba9601959 (diff)
chests, item dropping
Diffstat (limited to 'src/mob.cpp')
-rw-r--r--src/mob.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mob.cpp b/src/mob.cpp
index 20273d6..99d6f34 100644
--- a/src/mob.cpp
+++ b/src/mob.cpp
@@ -432,11 +432,26 @@ Chest::Chest(void) : Mob()
width = HLINES(10);
height = HLINES(5);
tex = TextureIterator({"assets/chest.png"});
+ inv = new Inventory(1);
}
void Chest::act(void)
{
- //die();
+ if (isInside(ui::mouse) && player->isNear(this)) {
+ if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) && !ui::dialogBoxExists)
+ for (auto &i : inv->Items) {
+ player->inv->addItem(i.first->name, i.second);
+ inv->takeItem(i.first->name, i.second);
+ }
+ }
+
+ for (auto &e : currentWorld->entity) {
+ if (e->type == OBJECTT && e->isNear(this)) {
+ auto o = dynamic_cast<Object *>(e);
+ inv->addItem(o->iname, 1);
+ e->health = 0;
+ }
+ }
}
void Chest::onHit(unsigned int _health)