~openmw/openmw/openmw-packaging2

« back to all changes in this revision

Viewing changes to apps/openmw/mwclass/container.cpp

  • Committer: Scott Howard
  • Date: 2016-09-15 20:56:29 UTC
  • Revision ID: showard@debian.org-20160915205629-3tvfxe47zrb41a91
Cron update. Git hash: 37278b5

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#include "../mwbase/world.hpp"
8
8
#include "../mwbase/windowmanager.hpp"
9
9
#include "../mwbase/mechanicsmanager.hpp"
 
10
#include "../mwbase/soundmanager.hpp"
10
11
 
11
12
#include "../mwworld/ptr.hpp"
12
13
#include "../mwworld/failedaction.hpp"
136
137
        MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
137
138
        MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
138
139
 
139
 
        bool needKey = ptr.getCellRef().getLockLevel() > 0;
 
140
        bool isLocked = ptr.getCellRef().getLockLevel() > 0;
 
141
        bool isTrapped = !ptr.getCellRef().getTrap().empty();
140
142
        bool hasKey = false;
141
143
        std::string keyName;
142
144
 
154
156
            }
155
157
        }
156
158
 
157
 
        if (needKey && hasKey)
 
159
        if ((isLocked || isTrapped) && hasKey)
158
160
        {
159
161
            MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
160
 
            unlock(ptr);
 
162
            if(isLocked)
 
163
                unlock(ptr);
161
164
            // using a key disarms the trap
162
 
            ptr.getCellRef().setTrap("");
 
165
            if(isTrapped)
 
166
            {
 
167
                ptr.getCellRef().setTrap("");
 
168
                MWBase::Environment::get().getSoundManager()->playSound3D(ptr,
 
169
                    "Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx,
 
170
                    MWBase::SoundManager::Play_Normal);
 
171
                isTrapped = false;
 
172
            }
163
173
        }
164
174
 
165
175
 
166
 
        if (!needKey || hasKey)
 
176
        if (!isLocked || hasKey)
167
177
        {
168
 
            if(ptr.getCellRef().getTrap().empty())
 
178
            if(!isTrapped)
169
179
            {
170
180
                boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
171
181
                return action;
173
183
            else
174
184
            {
175
185
                // Activate trap
176
 
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(actor, ptr.getCellRef().getTrap(), ptr));
 
186
                boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr));
177
187
                action->setSound(trapActivationSound);
178
188
                return action;
179
189
            }