1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-13 05:13:06 +00:00

Merge branch 'uses' into 'master'

Handle 0-use items like vanilla (bug #5611)

Closes #5611

See merge request OpenMW/openmw!306
This commit is contained in:
psi29a 2020-09-29 08:20:56 +00:00
commit f1ab519fac
3 changed files with 14 additions and 8 deletions

View file

@ -48,6 +48,7 @@
Bug #5548: Certain exhausted topics can be highlighted again even though there's no new dialogue Bug #5548: Certain exhausted topics can be highlighted again even though there's no new dialogue
Bug #5557: Diagonal movement is noticeably slower with analogue stick Bug #5557: Diagonal movement is noticeably slower with analogue stick
Bug #5603: Setting constant effect cast style doesn't correct effects view Bug #5603: Setting constant effect cast style doesn't correct effects view
Bug #5611: Usable items with "0 Uses" should be used only once
Feature #390: 3rd person look "over the shoulder" Feature #390: 3rd person look "over the shoulder"
Feature #2386: Distant Statics in the form of Object Paging Feature #2386: Distant Statics in the form of Object Paging
Feature #4894: Consider actors as obstacles for pathfinding Feature #4894: Consider actors as obstacles for pathfinding

View file

@ -27,7 +27,8 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
// reduce number of uses left // reduce number of uses left
int uses = mTool.getClass().getItemHealth(mTool); int uses = mTool.getClass().getItemHealth(mTool);
mTool.getCellRef().setCharge(uses-1); uses -= std::min(uses, 1);
mTool.getCellRef().setCharge(uses);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);

View file

@ -33,6 +33,10 @@ namespace MWMechanics
!lock.getClass().hasToolTip(lock)) //If it's unlocked or can not be unlocked back out immediately !lock.getClass().hasToolTip(lock)) //If it's unlocked or can not be unlocked back out immediately
return; return;
int uses = lockpick.getClass().getItemHealth(lockpick);
if (uses == 0)
return;
int lockStrength = lock.getCellRef().getLockLevel(); int lockStrength = lock.getCellRef().getLockLevel();
float pickQuality = lockpick.get<ESM::Lockpick>()->mBase->mData.mQuality; float pickQuality = lockpick.get<ESM::Lockpick>()->mBase->mData.mQuality;
@ -61,9 +65,7 @@ namespace MWMechanics
resultMessage = "#{sLockFail}"; resultMessage = "#{sLockFail}";
} }
int uses = lockpick.getClass().getItemHealth(lockpick); lockpick.getCellRef().setCharge(uses-1);
--uses;
lockpick.getCellRef().setCharge(uses);
if (!uses) if (!uses)
lockpick.getContainerStore()->remove(lockpick, 1, mActor); lockpick.getContainerStore()->remove(lockpick, 1, mActor);
} }
@ -71,7 +73,11 @@ namespace MWMechanics
void Security::probeTrap(const MWWorld::Ptr &trap, const MWWorld::Ptr &probe, void Security::probeTrap(const MWWorld::Ptr &trap, const MWWorld::Ptr &probe,
std::string& resultMessage, std::string& resultSound) std::string& resultMessage, std::string& resultSound)
{ {
if (trap.getCellRef().getTrap() == "") if (trap.getCellRef().getTrap().empty())
return;
int uses = probe.getClass().getItemHealth(probe);
if (uses == 0)
return; return;
float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality; float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality;
@ -104,9 +110,7 @@ namespace MWMechanics
resultMessage = "#{sTrapFail}"; resultMessage = "#{sTrapFail}";
} }
int uses = probe.getClass().getItemHealth(probe); probe.getCellRef().setCharge(uses-1);
--uses;
probe.getCellRef().setCharge(uses);
if (!uses) if (!uses)
probe.getContainerStore()->remove(probe, 1, mActor); probe.getContainerStore()->remove(probe, 1, mActor);
} }