1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +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 #5557: Diagonal movement is noticeably slower with analogue stick
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 #2386: Distant Statics in the form of Object Paging
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
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);

View File

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