[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:
balrok 2009-10-19 20:25:02 +02:00
parent 58139610eb
commit e990d5c509
12 changed files with 24 additions and 36 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL, `version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0', `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'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
-- --

View 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);

View file

@ -136,6 +136,7 @@ pkgdata_DATA = \
8608_02_mangos_battleground_events.sql \ 8608_02_mangos_battleground_events.sql \
8618_01_mangos_spell_proc_event.sql \ 8618_01_mangos_spell_proc_event.sql \
8676_01_mangos_creature_template.sql \ 8676_01_mangos_creature_template.sql \
8688_01_mangos_creature_template.sql \
README README
## Additional files to include when running 'make dist' ## Additional files to include when running 'make dist'
@ -252,4 +253,5 @@ EXTRA_DIST = \
8608_02_mangos_battleground_events.sql \ 8608_02_mangos_battleground_events.sql \
8618_01_mangos_spell_proc_event.sql \ 8618_01_mangos_spell_proc_event.sql \
8676_01_mangos_creature_template.sql \ 8676_01_mangos_creature_template.sql \
8688_01_mangos_creature_template.sql \
README README

View file

@ -19,6 +19,7 @@
#include "AggressorAI.h" #include "AggressorAI.h"
#include "Errors.h" #include "Errors.h"
#include "Creature.h" #include "Creature.h"
#include "SharedDefines.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "VMapFactory.h" #include "VMapFactory.h"
#include "World.h" #include "World.h"
@ -46,7 +47,7 @@ AggressorAI::MoveInLineOfSight(Unit *u)
if( !m_creature->canFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) if( !m_creature->canFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE )
return; 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() )*/ ) && ( m_creature->IsHostileTo( u ) /*|| u->getVictim() && m_creature->IsFriendlyTo( u->getVictim() )*/ ) &&
u->isInAccessablePlaceFor(m_creature) ) u->isInAccessablePlaceFor(m_creature) )
{ {

View file

@ -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 // 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(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 false;
return (isAlive() || m_deathTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE)); return (isAlive() || m_deathTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE));
} }
@ -1766,8 +1766,8 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
} }
} }
// Dead player see ghosts // Dead player can see ghosts
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST) if (GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_GHOST_VISIBLE)
return true; return true;
// and not see any other // and not see any other

View file

@ -143,7 +143,6 @@ enum CreatureFlagsExtra
CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP 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_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_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 // 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

View file

@ -2072,24 +2072,10 @@ void Player::RegenerateHealth(uint32 diff)
ModifyHealth(int32(addvalue)); ModifyHealth(int32(addvalue));
} }
bool Player::CanInteractWithNPCs(bool alive) const Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
{
if(alive && !isAlive())
return false;
if(isInFlight())
return false;
return true;
}
Creature*
Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
{ {
// unit checks // unit checks
if (!guid) if (!guid || !IsInWorld() || isInFlight())
return NULL;
if(!IsInWorld())
return NULL; return NULL;
// exist (we need look pets also for some interaction (quest/etc) // exist (we need look pets also for some interaction (quest/etc)
@ -2097,23 +2083,20 @@ Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
if (!unit) if (!unit)
return NULL; return NULL;
// player check
if(!CanInteractWithNPCs(!(unit->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST)))
return NULL;
// appropriate npc type // appropriate npc type
if(npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask )) if (npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
return NULL; 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; return NULL;
// not allow interaction under control, but allow with own pets // not allow interaction under control, but allow with own pets
if(unit->GetCharmerGUID()) if (unit->GetCharmerGUID())
return NULL; return NULL;
// not enemy // not enemy
if( unit->IsHostileTo(this)) if (unit->IsHostileTo(this))
return NULL; return NULL;
// not unfriendly // not unfriendly

View file

@ -1046,7 +1046,6 @@ class MANGOS_DLL_SPEC Player : public Unit
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time); void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time);
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask); Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
bool CanInteractWithNPCs(bool alive = true) const;
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const; GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
void UpdateVisibilityForPlayer(); void UpdateVisibilityForPlayer();

View file

@ -1884,7 +1884,7 @@ enum CreatureFamily
enum CreatureTypeFlags enum CreatureTypeFlags
{ {
CREATURE_TYPEFLAGS_TAMEABLE = 0x000001, // Tameable by any hunter 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_UNK3 = 0x000004,
CREATURE_TYPEFLAGS_UNK4 = 0x000008, CREATURE_TYPEFLAGS_UNK4 = 0x000008,
CREATURE_TYPEFLAGS_UNK5 = 0x000010, CREATURE_TYPEFLAGS_UNK5 = 0x000010,

View file

@ -9603,8 +9603,7 @@ bool Unit::isTargetableForAttack(bool inverseAlive /*=false*/) const
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE)) if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE))
return false; return false;
// target is dead or has ghost-flag if (!(isAlive() != inverseAlive))
if ((!isAlive() || (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST)) != inverseAlive)
return false; return false;
return IsInWorld() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/; return IsInWorld() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8687" #define REVISION_NR "8688"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__ #ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__ #define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_8596_01_characters_bugreport" #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" #define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters"
#endif // __REVISION_SQL_H__ #endif // __REVISION_SQL_H__