Fix issue #109
This commit is contained in:
parent
ced5c035b9
commit
fa8b77f0c8
|
@ -41,6 +41,7 @@ function init()
|
|||
connect(Creature, {
|
||||
onSkullChange = updateCreatureSkull,
|
||||
onEmblemChange = updateCreatureEmblem,
|
||||
onOutfitChange = onCreatureOutfitChange,
|
||||
onHealthPercentChange = onCreatureHealthPercentChange,
|
||||
onPositionChange = onCreaturePositionChange,
|
||||
onAppear = onCreatureAppear,
|
||||
|
@ -67,6 +68,7 @@ function terminate()
|
|||
disconnect(Creature, {
|
||||
onSkullChange = updateCreatureSkull,
|
||||
onEmblemChange = updateCreatureEmblem,
|
||||
onOutfitChange = onCreatureOutfitChange,
|
||||
onHealthPercentChange = onCreatureHealthPercentChange,
|
||||
onPositionChange = onCreaturePositionChange,
|
||||
onAppear = onCreatureAppear,
|
||||
|
@ -126,6 +128,8 @@ function doCreatureFitFilters(creature)
|
|||
return false
|
||||
end
|
||||
|
||||
if not creature:canBeSeen() then return false end
|
||||
|
||||
local hidePlayers = hidePlayersButton:isChecked()
|
||||
local hideNPCs = hideNPCsButton:isChecked()
|
||||
local hideMonsters = hideMonstersButton:isChecked()
|
||||
|
@ -168,9 +172,17 @@ function onCreaturePositionChange(creature, newPos, oldPos)
|
|||
end
|
||||
end
|
||||
|
||||
function onCreatureOutfitChange(creature, outfit, oldOutfit)
|
||||
if not creature:canBeSeen() then
|
||||
removeCreature(creature)
|
||||
elseif doCreatureFitFilters(creature) then
|
||||
removeCreature(creature)
|
||||
addCreature(creature)
|
||||
end
|
||||
end
|
||||
|
||||
function onCreatureAppear(creature)
|
||||
local player = g_game.getLocalPlayer()
|
||||
if creature ~= player and creature:getPosition().z == player:getPosition().z and doCreatureFitFilters(creature) then
|
||||
if doCreatureFitFilters(creature) then
|
||||
addCreature(creature)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,6 +60,9 @@ Creature::Creature() : Thing()
|
|||
|
||||
void Creature::draw(const Point& dest, float scaleFactor, bool animate)
|
||||
{
|
||||
if(!canBeSeen())
|
||||
return;
|
||||
|
||||
Point animationOffset = animate ? m_walkOffset : Point(0,0);
|
||||
|
||||
if(m_showTimedSquare && animate) {
|
||||
|
@ -523,6 +526,7 @@ void Creature::setDirection(Otc::Direction direction)
|
|||
|
||||
void Creature::setOutfit(const Outfit& outfit)
|
||||
{
|
||||
Outfit oldOutfit = outfit;
|
||||
if(outfit.getCategory() != ThingCategoryCreature) {
|
||||
if(!g_things.isValidDatId(outfit.getAuxId(), outfit.getCategory()))
|
||||
return;
|
||||
|
@ -534,6 +538,8 @@ void Creature::setOutfit(const Outfit& outfit)
|
|||
m_outfit = outfit;
|
||||
}
|
||||
m_walkAnimationPhase = 0; // might happen when player is walking and outfit is changed.
|
||||
|
||||
callLuaField("onOutfitChange", m_outfit, oldOutfit);
|
||||
}
|
||||
|
||||
void Creature::setSpeed(uint16 speed)
|
||||
|
|
|
@ -102,6 +102,8 @@ public:
|
|||
|
||||
bool isWalking() { return m_walking; }
|
||||
bool isRemoved() { return m_removed; }
|
||||
bool isInvisible() { return m_outfit.getCategory() == ThingCategoryEffect && m_outfit.getAuxId() == 13; }
|
||||
bool canBeSeen() { return !isInvisible() || isPlayer(); }
|
||||
|
||||
bool isCreature() { return true; }
|
||||
|
||||
|
|
|
@ -368,6 +368,8 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Creature>("showStaticSquare", &Creature::showStaticSquare);
|
||||
g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare);
|
||||
g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);
|
||||
g_lua.bindClassMemberFunction<Creature>("isInvisible", &Creature::isInvisible);
|
||||
g_lua.bindClassMemberFunction<Creature>("canBeSeen", &Creature::canBeSeen);
|
||||
|
||||
g_lua.registerClass<ItemType>();
|
||||
g_lua.bindClassMemberFunction<ItemType>("getServerId", &ItemType::getServerId);
|
||||
|
|
|
@ -28,6 +28,8 @@ int push_luavalue(const Outfit& outfit)
|
|||
g_lua.newTable();
|
||||
g_lua.pushInteger(outfit.getId());
|
||||
g_lua.setField("type");
|
||||
g_lua.pushInteger(outfit.getAuxId());
|
||||
g_lua.setField("auxType");
|
||||
g_lua.pushInteger(outfit.getAddons());
|
||||
g_lua.setField("addons");
|
||||
g_lua.pushInteger(outfit.getHead());
|
||||
|
@ -50,6 +52,8 @@ bool luavalue_cast(int index, Outfit& outfit)
|
|||
if(g_lua.isTable(index)) {
|
||||
g_lua.getField("type", index);
|
||||
outfit.setId(g_lua.popInteger());
|
||||
g_lua.getField("auxType", index);
|
||||
outfit.setAuxId(g_lua.popInteger());
|
||||
g_lua.getField("addons", index);
|
||||
outfit.setAddons(g_lua.popInteger());
|
||||
g_lua.getField("head", index);
|
||||
|
|
|
@ -175,6 +175,9 @@ void MapView::draw(const Rect& rect)
|
|||
// avoid drawing texts on map in far zoom outs
|
||||
if(m_viewMode == NEAR_VIEW && m_drawTexts) {
|
||||
for(const CreaturePtr& creature : m_cachedFloorVisibleCreatures) {
|
||||
if(!creature->canBeSeen())
|
||||
continue;
|
||||
|
||||
Point creatureOffset = Point(16 - creature->getDisplacementX(), -3 - creature->getDisplacementY());
|
||||
Position pos = creature->getPosition();
|
||||
Point p = transformPositionTo2D(pos, cameraPosition) - drawOffset;
|
||||
|
|
|
@ -451,7 +451,7 @@ bool Tile::isWalkable()
|
|||
|
||||
if(thing->isCreature()) {
|
||||
CreaturePtr creature = thing->static_self_cast<Creature>();
|
||||
if(!creature->isPassable())
|
||||
if(!creature->isPassable() && creature->canBeSeen())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue