mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[8688] proper implementation of creatures ghost-flags
this reverts 8676 (9c50d9e70314b0cd9eb0fe3bac8040d64a9965a5) the new flag is from wdb-files so your database should be already alright also i've dropped the function Player::CanInteractWithNPCs cause it was used only in one place and didn't seem to make anything easier NOTE for this flag: it just means that the creature can be seen by ghost-players too.. so they are still visible for alive players.. unless a special aura or ther unitflag (spiritguide/healer) disables this.. (see next commit for it)
This commit is contained in:
parent
58139610eb
commit
e990d5c509
12 changed files with 24 additions and 36 deletions
|
|
@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
|
|||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`cache_id` int(10) default '0',
|
||||
`required_8676_01_mangos_creature_template` bit(1) default NULL
|
||||
`required_8688_01_mangos_creature_template` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
|
|||
5
sql/updates/8688_01_mangos_creature_template.sql
Normal file
5
sql/updates/8688_01_mangos_creature_template.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_8676_01_mangos_creature_template required_8688_01_mangos_creature_template bit;
|
||||
|
||||
-- reverts last update - we now have something better
|
||||
UPDATE creature_template SET flags_extra = flags_extra & ~(0x200) WHERE npcflag
|
||||
& (16384|32768);
|
||||
|
|
@ -136,6 +136,7 @@ pkgdata_DATA = \
|
|||
8608_02_mangos_battleground_events.sql \
|
||||
8618_01_mangos_spell_proc_event.sql \
|
||||
8676_01_mangos_creature_template.sql \
|
||||
8688_01_mangos_creature_template.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -252,4 +253,5 @@ EXTRA_DIST = \
|
|||
8608_02_mangos_battleground_events.sql \
|
||||
8618_01_mangos_spell_proc_event.sql \
|
||||
8676_01_mangos_creature_template.sql \
|
||||
8688_01_mangos_creature_template.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "AggressorAI.h"
|
||||
#include "Errors.h"
|
||||
#include "Creature.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "World.h"
|
||||
|
|
@ -46,7 +47,7 @@ AggressorAI::MoveInLineOfSight(Unit *u)
|
|||
if( !m_creature->canFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE )
|
||||
return;
|
||||
|
||||
if( !(m_creature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST) && !m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && u->isTargetableForAttack() &&
|
||||
if (!m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && u->isTargetableForAttack() &&
|
||||
( m_creature->IsHostileTo( u ) /*|| u->getVictim() && m_creature->IsFriendlyTo( u->getVictim() )*/ ) &&
|
||||
u->isInAccessablePlaceFor(m_creature) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1749,7 +1749,7 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
|
|||
// Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0
|
||||
if(pl->isAlive() || pl->GetDeathTimer() > 0)
|
||||
{
|
||||
if(GetCreatureInfo()->flags_extra & (CREATURE_FLAG_EXTRA_INVISIBLE | CREATURE_FLAG_EXTRA_GHOST))
|
||||
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE)
|
||||
return false;
|
||||
return (isAlive() || m_deathTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE));
|
||||
}
|
||||
|
|
@ -1766,8 +1766,8 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
|
|||
}
|
||||
}
|
||||
|
||||
// Dead player see ghosts
|
||||
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST)
|
||||
// Dead player can see ghosts
|
||||
if (GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_GHOST_VISIBLE)
|
||||
return true;
|
||||
|
||||
// and not see any other
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ enum CreatureFlagsExtra
|
|||
CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
|
||||
CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
|
||||
CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me
|
||||
CREATURE_FLAG_EXTRA_GHOST = 0x00000200, // creature is only visible for dead players
|
||||
};
|
||||
|
||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
|
||||
|
|
|
|||
|
|
@ -2072,24 +2072,10 @@ void Player::RegenerateHealth(uint32 diff)
|
|||
ModifyHealth(int32(addvalue));
|
||||
}
|
||||
|
||||
bool Player::CanInteractWithNPCs(bool alive) const
|
||||
{
|
||||
if(alive && !isAlive())
|
||||
return false;
|
||||
if(isInFlight())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Creature*
|
||||
Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
||||
Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
||||
{
|
||||
// unit checks
|
||||
if (!guid)
|
||||
return NULL;
|
||||
|
||||
if(!IsInWorld())
|
||||
if (!guid || !IsInWorld() || isInFlight())
|
||||
return NULL;
|
||||
|
||||
// exist (we need look pets also for some interaction (quest/etc)
|
||||
|
|
@ -2097,23 +2083,20 @@ Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
|||
if (!unit)
|
||||
return NULL;
|
||||
|
||||
// player check
|
||||
if(!CanInteractWithNPCs(!(unit->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST)))
|
||||
return NULL;
|
||||
|
||||
// appropriate npc type
|
||||
if(npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
|
||||
if (npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
|
||||
return NULL;
|
||||
|
||||
if (isAlive() && !unit->isAlive())
|
||||
// if a dead unit should be able to talk - the creature must be alive and have special flags
|
||||
if (!unit->isAlive())
|
||||
return NULL;
|
||||
|
||||
// not allow interaction under control, but allow with own pets
|
||||
if(unit->GetCharmerGUID())
|
||||
if (unit->GetCharmerGUID())
|
||||
return NULL;
|
||||
|
||||
// not enemy
|
||||
if( unit->IsHostileTo(this))
|
||||
if (unit->IsHostileTo(this))
|
||||
return NULL;
|
||||
|
||||
// not unfriendly
|
||||
|
|
|
|||
|
|
@ -1046,7 +1046,6 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
|
||||
|
||||
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
|
||||
bool CanInteractWithNPCs(bool alive = true) const;
|
||||
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
|
||||
|
||||
void UpdateVisibilityForPlayer();
|
||||
|
|
|
|||
|
|
@ -1884,7 +1884,7 @@ enum CreatureFamily
|
|||
enum CreatureTypeFlags
|
||||
{
|
||||
CREATURE_TYPEFLAGS_TAMEABLE = 0x000001, // Tameable by any hunter
|
||||
CREATURE_TYPEFLAGS_GHOST = 0x000002, // Creature are also visible for not alive player. Allow gossip interaction if npcflag allow?
|
||||
CREATURE_TYPEFLAGS_GHOST_VISIBLE = 0x000002, // Creatures which can _also_ be seen when player is a ghost
|
||||
CREATURE_TYPEFLAGS_UNK3 = 0x000004,
|
||||
CREATURE_TYPEFLAGS_UNK4 = 0x000008,
|
||||
CREATURE_TYPEFLAGS_UNK5 = 0x000010,
|
||||
|
|
|
|||
|
|
@ -9603,8 +9603,7 @@ bool Unit::isTargetableForAttack(bool inverseAlive /*=false*/) const
|
|||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE))
|
||||
return false;
|
||||
|
||||
// target is dead or has ghost-flag
|
||||
if ((!isAlive() || (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST)) != inverseAlive)
|
||||
if (!(isAlive() != inverseAlive))
|
||||
return false;
|
||||
|
||||
return IsInWorld() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8687"
|
||||
#define REVISION_NR "8688"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_8596_01_characters_bugreport"
|
||||
#define REVISION_DB_MANGOS "required_8676_01_mangos_creature_template"
|
||||
#define REVISION_DB_MANGOS "required_8688_01_mangos_creature_template"
|
||||
#define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue