diff --git a/sql/mangos.sql b/sql/mangos.sql index 26d1b3c5f..0a03d0cf3 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -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'; -- diff --git a/sql/updates/8688_01_mangos_creature_template.sql b/sql/updates/8688_01_mangos_creature_template.sql new file mode 100644 index 000000000..02540006d --- /dev/null +++ b/sql/updates/8688_01_mangos_creature_template.sql @@ -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); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 5137ff8d4..9198d0d4a 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -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 diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index faa4e608d..f611a87b6 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -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) ) { diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index b666a0289..c15da2c44 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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 diff --git a/src/game/Creature.h b/src/game/Creature.h index d41364ce2..f0025a9c6 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -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 diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 38920cf5d..20aff8838 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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 diff --git a/src/game/Player.h b/src/game/Player.h index ff6a185d3..5533110c1 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -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(); diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 8021243fb..45762a66f 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -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, diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index eb01b162b..4d3a51a32 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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()*/; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 9e02251d4..eee8b347d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8687" + #define REVISION_NR "8688" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 55c964243..faf8d488d 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.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__