Make Detect Life spell detect NPCs when in werewolf form (Fixes #1527)

deque
scrawl 11 years ago
parent 4f9ebd148c
commit 1244da85df

@ -384,6 +384,8 @@ namespace MWGui
void HUD::onFrame(float dt) void HUD::onFrame(float dt)
{ {
LocalMapBase::onFrame(dt);
mCellNameTimer -= dt; mCellNameTimer -= dt;
mWeaponSpellTimer -= dt; mWeaponSpellTimer -= dt;
if (mCellNameTimer < 0) if (mCellNameTimer < 0)

@ -36,6 +36,7 @@ namespace MWGui
, mLastDirectionX(0.0f) , mLastDirectionX(0.0f)
, mLastDirectionY(0.0f) , mLastDirectionY(0.0f)
, mCompass(NULL) , mCompass(NULL)
, mMarkerUpdateTimer(0.0f)
{ {
} }
@ -345,6 +346,18 @@ namespace MWGui
markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserString("IsMarker", "true");
markerWidget->setUserData(markerPos); markerWidget->setUserData(markerPos);
markerWidget->setColour(markerColour); markerWidget->setColour(markerColour);
mMarkerWidgets.push_back(markerWidget);
}
}
void LocalMapBase::onFrame(float dt)
{
mMarkerUpdateTimer += dt;
if (mMarkerUpdateTimer >= 0.25)
{
mMarkerUpdateTimer = 0;
updateMarkers();
} }
} }
@ -471,6 +484,8 @@ namespace MWGui
void MapWindow::onFrame(float dt) void MapWindow::onFrame(float dt)
{ {
LocalMapBase::onFrame(dt);
for (std::vector<CellId>::iterator it = mQueuedToExplore.begin(); it != mQueuedToExplore.end(); ++it) for (std::vector<CellId>::iterator it = mQueuedToExplore.begin(); it != mQueuedToExplore.end(); ++it)
{ {
mGlobalMapRender->exploreCell(it->first, it->second); mGlobalMapRender->exploreCell(it->first, it->second);

@ -35,6 +35,8 @@ namespace MWGui
void setPlayerDir(const float x, const float y); void setPlayerDir(const float x, const float y);
void setPlayerPos(const float x, const float y); void setPlayerPos(const float x, const float y);
void onFrame(float dt);
bool toggleFogOfWar(); bool toggleFogOfWar();
struct MarkerPosition struct MarkerPosition
@ -73,12 +75,14 @@ namespace MWGui
virtual void notifyMapChanged() {} virtual void notifyMapChanged() {}
// Update markers (Detect X effects, Mark/Recall effects) // Update markers (Detect X effects, Mark/Recall effects)
// Note, door markers handled in setActiveCell // Note, door markers are handled in setActiveCell
void updateMarkers(); void updateMarkers();
void addDetectionMarkers(int type); void addDetectionMarkers(int type);
OEngine::GUI::Layout* mLayout; OEngine::GUI::Layout* mLayout;
float mMarkerUpdateTimer;
bool mMapDragAndDrop; bool mMapDragAndDrop;
float mLastPositionX; float mLastPositionX;

@ -2445,14 +2445,15 @@ namespace MWWorld
if (!ptr.getRefData().isEnabled()) if (!ptr.getRefData().isEnabled())
return true; return true;
// Consider references inside containers as well // Consider references inside containers as well (except if we are looking for a Creature, they cannot be in containers)
if (ptr.getClass().isActor() || ptr.getClass().getTypeName() == typeid(ESM::Container).name()) if (mType != World::Detect_Creature &&
(ptr.getClass().isActor() || ptr.getClass().getTypeName() == typeid(ESM::Container).name()))
{ {
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr); MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
{ {
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
{ {
if (needToAdd(*it)) if (needToAdd(*it, mDetector))
{ {
mOut.push_back(ptr); mOut.push_back(ptr);
return true; return true;
@ -2461,16 +2462,25 @@ namespace MWWorld
} }
} }
if (needToAdd(ptr)) if (needToAdd(ptr, mDetector))
mOut.push_back(ptr); mOut.push_back(ptr);
return true; return true;
} }
bool needToAdd (MWWorld::Ptr ptr) bool needToAdd (MWWorld::Ptr ptr, MWWorld::Ptr detector)
{ {
if (mType == World::Detect_Creature && ptr.getClass().getTypeName() != typeid(ESM::Creature).name()) if (mType == World::Detect_Creature)
return false; {
// If in werewolf form, this detects only NPCs, otherwise only creatures
if (detector.getClass().isNpc() && detector.getClass().getNpcStats(detector).isWerewolf())
{
if (ptr.getClass().getTypeName() != typeid(ESM::NPC).name())
return false;
}
else if (ptr.getClass().getTypeName() != typeid(ESM::Creature).name())
return false;
}
if (mType == World::Detect_Key && !ptr.getClass().isKey(ptr)) if (mType == World::Detect_Key && !ptr.getClass().isKey(ptr))
return false; return false;
if (mType == World::Detect_Enchantment && ptr.getClass().getEnchantment(ptr).empty()) if (mType == World::Detect_Enchantment && ptr.getClass().getEnchantment(ptr).empty())

Loading…
Cancel
Save