Add WorldEffectID to Gameobject

This commit is contained in:
hondacrx
2017-11-05 17:40:57 -05:00
parent f81a877ad3
commit b8fe68ec8b
8 changed files with 78 additions and 22 deletions
@@ -33,7 +33,7 @@ namespace Framework.Constants
Rotation = 0x80, Rotation = 0x80,
AnimKits = 0x100, AnimKits = 0x100,
Areatrigger = 0x0200, Areatrigger = 0x0200,
//UPDATEFLAG_GAMEOBJECT = 0x0400, Gameobject = 0x0400,
//UPDATEFLAG_REPLACE_ACTIVE = 0x0800, //UPDATEFLAG_REPLACE_ACTIVE = 0x0800,
//UPDATEFLAG_NO_BIRTH_ANIM = 0x1000, //UPDATEFLAG_NO_BIRTH_ANIM = 0x1000,
//UPDATEFLAG_ENABLE_PORTALS = 0x2000, //UPDATEFLAG_ENABLE_PORTALS = 0x2000,
@@ -990,6 +990,10 @@ namespace Framework.Database
"UWAmbience, NameSet, SoundProviderPref, SoundProviderPrefUnderwater, Flags, ID, UWZoneMusic FROM wmo_area_table ORDER BY ID DESC"); "UWAmbience, NameSet, SoundProviderPref, SoundProviderPrefUnderwater, Flags, ID, UWZoneMusic FROM wmo_area_table ORDER BY ID DESC");
PrepareStatement(HotfixStatements.SEL_WMO_AREA_TABLE_LOCALE, "SELECT ID, AreaName_lang FROM wmo_area_table_locale WHERE locale = ?"); PrepareStatement(HotfixStatements.SEL_WMO_AREA_TABLE_LOCALE, "SELECT ID, AreaName_lang FROM wmo_area_table_locale WHERE locale = ?");
// WorldEffect.db2
PrepareStatement(HotfixStatements.SEL_WORLD_EFFECT, "SELECT ID, TargetAsset, CombatConditionID, TargetType, WhenToDisplay, QuestFeedbackEffectID, " +
"PlayerConditionID FROM world_effect ORDER BY ID DESC");
// WorldMapArea.db2 // WorldMapArea.db2
PrepareStatement(HotfixStatements.SEL_WORLD_MAP_AREA, "SELECT AreaName, LocLeft, LocRight, LocTop, LocBottom, MapID, AreaID, DisplayMapID, " + PrepareStatement(HotfixStatements.SEL_WORLD_MAP_AREA, "SELECT AreaName, LocLeft, LocRight, LocTop, LocBottom, MapID, AreaID, DisplayMapID, " +
"DefaultDungeonFloor, ParentWorldMapID, Flags, LevelRangeMin, LevelRangeMax, BountySetID, BountyBoardLocation, ID, PlayerConditionID" + "DefaultDungeonFloor, ParentWorldMapID, Flags, LevelRangeMin, LevelRangeMax, BountySetID, BountyBoardLocation, ID, PlayerConditionID" +
@@ -1517,6 +1521,8 @@ namespace Framework.Database
SEL_WMO_AREA_TABLE, SEL_WMO_AREA_TABLE,
SEL_WMO_AREA_TABLE_LOCALE, SEL_WMO_AREA_TABLE_LOCALE,
SEL_WORLD_EFFECT,
SEL_WORLD_MAP_AREA, SEL_WORLD_MAP_AREA,
SEL_WORLD_MAP_OVERLAY, SEL_WORLD_MAP_OVERLAY,
+2
View File
@@ -252,6 +252,7 @@ namespace Game.DataStorage
VehicleStorage = DB6Reader.Read<VehicleRecord>("Vehicle.db2", DB6Metas.VehicleMeta, HotfixStatements.SEL_VEHICLE); VehicleStorage = DB6Reader.Read<VehicleRecord>("Vehicle.db2", DB6Metas.VehicleMeta, HotfixStatements.SEL_VEHICLE);
VehicleSeatStorage = DB6Reader.Read<VehicleSeatRecord>("VehicleSeat.db2", DB6Metas.VehicleSeatMeta, HotfixStatements.SEL_VEHICLE_SEAT); VehicleSeatStorage = DB6Reader.Read<VehicleSeatRecord>("VehicleSeat.db2", DB6Metas.VehicleSeatMeta, HotfixStatements.SEL_VEHICLE_SEAT);
WMOAreaTableStorage = DB6Reader.Read<WMOAreaTableRecord>("WMOAreaTable.db2", DB6Metas.WMOAreaTableMeta, HotfixStatements.SEL_WMO_AREA_TABLE, HotfixStatements.SEL_WMO_AREA_TABLE_LOCALE); WMOAreaTableStorage = DB6Reader.Read<WMOAreaTableRecord>("WMOAreaTable.db2", DB6Metas.WMOAreaTableMeta, HotfixStatements.SEL_WMO_AREA_TABLE, HotfixStatements.SEL_WMO_AREA_TABLE_LOCALE);
WorldEffectStorage = DB6Reader.Read<WorldEffectRecord>("WorldEffect.db2", DB6Metas.WorldEffectMeta, HotfixStatements.SEL_WORLD_EFFECT);
WorldMapAreaStorage = DB6Reader.Read<WorldMapAreaRecord>("WorldMapArea.db2", DB6Metas.WorldMapAreaMeta, HotfixStatements.SEL_WORLD_MAP_AREA); WorldMapAreaStorage = DB6Reader.Read<WorldMapAreaRecord>("WorldMapArea.db2", DB6Metas.WorldMapAreaMeta, HotfixStatements.SEL_WORLD_MAP_AREA);
WorldMapOverlayStorage = DB6Reader.Read<WorldMapOverlayRecord>("WorldMapOverlay.db2", DB6Metas.WorldMapOverlayMeta, HotfixStatements.SEL_WORLD_MAP_OVERLAY); WorldMapOverlayStorage = DB6Reader.Read<WorldMapOverlayRecord>("WorldMapOverlay.db2", DB6Metas.WorldMapOverlayMeta, HotfixStatements.SEL_WORLD_MAP_OVERLAY);
WorldMapTransformsStorage = DB6Reader.Read<WorldMapTransformsRecord>("WorldMapTransforms.db2", DB6Metas.WorldMapTransformsMeta, HotfixStatements.SEL_WORLD_MAP_TRANSFORMS); WorldMapTransformsStorage = DB6Reader.Read<WorldMapTransformsRecord>("WorldMapTransforms.db2", DB6Metas.WorldMapTransformsMeta, HotfixStatements.SEL_WORLD_MAP_TRANSFORMS);
@@ -577,6 +578,7 @@ namespace Game.DataStorage
public static DB6Storage<VehicleRecord> VehicleStorage; public static DB6Storage<VehicleRecord> VehicleStorage;
public static DB6Storage<VehicleSeatRecord> VehicleSeatStorage; public static DB6Storage<VehicleSeatRecord> VehicleSeatStorage;
public static DB6Storage<WMOAreaTableRecord> WMOAreaTableStorage; public static DB6Storage<WMOAreaTableRecord> WMOAreaTableStorage;
public static DB6Storage<WorldEffectRecord> WorldEffectStorage;
public static DB6Storage<WorldMapAreaRecord> WorldMapAreaStorage; public static DB6Storage<WorldMapAreaRecord> WorldMapAreaStorage;
public static DB6Storage<WorldMapOverlayRecord> WorldMapOverlayStorage; public static DB6Storage<WorldMapOverlayRecord> WorldMapOverlayStorage;
public static DB6Storage<WorldMapTransformsRecord> WorldMapTransformsStorage; public static DB6Storage<WorldMapTransformsRecord> WorldMapTransformsStorage;
@@ -39,6 +39,17 @@ namespace Game.DataStorage
public uint UWZoneMusic; public uint UWZoneMusic;
} }
public sealed class WorldEffectRecord
{
public uint ID;
public uint TargetAsset;
public ushort CombatConditionID;
public byte TargetType;
public byte WhenToDisplay;
public uint QuestFeedbackEffectID;
public uint PlayerConditionID;
}
public sealed class WorldMapAreaRecord public sealed class WorldMapAreaRecord
{ {
public string AreaName; public string AreaName;
@@ -228,6 +228,12 @@ namespace Game.Entities
{ {
SetUInt32Value(GameObjectFields.Faction, m_goTemplateAddon.faction); SetUInt32Value(GameObjectFields.Faction, m_goTemplateAddon.faction);
SetUInt32Value(GameObjectFields.Flags, m_goTemplateAddon.flags); SetUInt32Value(GameObjectFields.Flags, m_goTemplateAddon.flags);
if (m_goTemplateAddon.WorldEffectID)
{
m_updateFlag |= UpdateFlag.Gameobject;
SetWorldEffectID(m_goTemplateAddon.WorldEffectID);
}
} }
SetEntry(goinfo.entry); SetEntry(goinfo.entry);
@@ -318,6 +324,12 @@ namespace Game.Entities
m_invisibility.AddValue(gameObjectAddon.invisibilityType, gameObjectAddon.invisibilityValue); m_invisibility.AddValue(gameObjectAddon.invisibilityType, gameObjectAddon.invisibilityValue);
} }
if (gameObjectAddon != null && gameObjectAddon.WorldEffectID)
{
m_updateFlag |= UpdateFlag.Gameobject;
SetWorldEffectID(gameObjectAddon.WorldEffectID);
}
LastUsedScriptID = GetGoInfo().ScriptId; LastUsedScriptID = GetGoInfo().ScriptId;
AIM_Initialize(); AIM_Initialize();
@@ -2498,6 +2510,9 @@ namespace Game.Entities
public override ushort GetAIAnimKitId() { return _animKitId; } public override ushort GetAIAnimKitId() { return _animKitId; }
public uint GetWorldEffectID() { return _worldEffectID; }
public void SetWorldEffectID(uint worldEffectID) { _worldEffectID = worldEffectID; }
public GameObjectTemplate GetGoInfo() { return m_goInfo; } public GameObjectTemplate GetGoInfo() { return m_goInfo; }
public GameObjectTemplateAddon GetTemplateAddon() { return m_goTemplateAddon; } public GameObjectTemplateAddon GetTemplateAddon() { return m_goTemplateAddon; }
GameObjectData GetGoData() { return m_goData; } GameObjectData GetGoData() { return m_goData; }
@@ -2663,6 +2678,7 @@ namespace Game.Entities
GameObjectAI m_AI; GameObjectAI m_AI;
ushort _animKitId; ushort _animKitId;
uint _worldEffectID;
GameObjectState m_prevGoState; // What state to set whenever resetting GameObjectState m_prevGoState; // What state to set whenever resetting
@@ -1030,6 +1030,7 @@ namespace Game.Entities
public uint flags; public uint flags;
public uint mingold; public uint mingold;
public uint maxgold; public uint maxgold;
public uint WorldEffectID;
} }
public class GameObjectLocale public class GameObjectLocale
@@ -1044,6 +1045,7 @@ namespace Game.Entities
public Quaternion ParentRotation; public Quaternion ParentRotation;
public InvisibilityType invisibilityType; public InvisibilityType invisibilityType;
public uint invisibilityValue; public uint invisibilityValue;
public uint WorldEffectID;
} }
public class GameObjectData public class GameObjectData
+14 -8
View File
@@ -325,7 +325,7 @@ namespace Game.Entities
bool AnimKitCreate = flags.HasAnyFlag(UpdateFlag.AnimKits); bool AnimKitCreate = flags.HasAnyFlag(UpdateFlag.AnimKits);
bool Rotation = flags.HasAnyFlag(UpdateFlag.Rotation); bool Rotation = flags.HasAnyFlag(UpdateFlag.Rotation);
bool HasAreaTrigger = flags.HasAnyFlag(UpdateFlag.Areatrigger); bool HasAreaTrigger = flags.HasAnyFlag(UpdateFlag.Areatrigger);
bool HasGameObject = false; bool HasGameObject = flags.HasAnyFlag(UpdateFlag.Gameobject);
bool ThisIsYou = flags.HasAnyFlag(UpdateFlag.Self); bool ThisIsYou = flags.HasAnyFlag(UpdateFlag.Self);
bool SmoothPhasing = false; bool SmoothPhasing = false;
bool SceneObjCreate = false; bool SceneObjCreate = false;
@@ -653,14 +653,20 @@ namespace Game.Entities
} }
} }
//if (HasGameObject) if (HasGameObject)
//{ {
// *data << uint32(WorldEffectID); bool bit8 = false;
uint Int1 = 0;
// data.WriteBit(bit8); GameObject gameObject = ToGameObject();
// if (bit8)
// *data << uint32(Int1); data.WriteUInt32(gameObject.GetWorldEffectID());
//}
data.WriteBit(bit8);
data.FlushBits();
if (bit8)
data.WriteUInt32(Int1);
}
//if (SmoothPhasing) //if (SmoothPhasing)
//{ //{
+26 -13
View File
@@ -3803,8 +3803,8 @@ namespace Game
{ {
uint oldMSTime = Time.GetMSTime(); uint oldMSTime = Time.GetMSTime();
// 0 1 2 3 4 // 0 1 2 3 4 5
SQLResult result = DB.World.Query("SELECT entry, faction, flags, mingold, maxgold FROM gameobject_template_addon"); SQLResult result = DB.World.Query("SELECT entry, faction, flags, mingold, maxgold, WorldEffectID FROM gameobject_template_addon");
if (result.IsEmpty()) if (result.IsEmpty())
{ {
@@ -3820,7 +3820,7 @@ namespace Game
GameObjectTemplate got = Global.ObjectMgr.GetGameObjectTemplate(entry); GameObjectTemplate got = Global.ObjectMgr.GetGameObjectTemplate(entry);
if (got == null) if (got == null)
{ {
Log.outError(LogFilter.Sql, "GameObject template (Entry: {0}) does not exist but has a record in `gameobject_template_addon`", entry); Log.outError(LogFilter.Sql, $"GameObject template (Entry: {entry}) does not exist but has a record in `gameobject_template_addon`");
continue; continue;
} }
@@ -3829,10 +3829,11 @@ namespace Game
gameObjectAddon.flags = result.Read<uint>(2); gameObjectAddon.flags = result.Read<uint>(2);
gameObjectAddon.mingold = result.Read<uint>(3); gameObjectAddon.mingold = result.Read<uint>(3);
gameObjectAddon.maxgold = result.Read<uint>(4); gameObjectAddon.maxgold = result.Read<uint>(4);
gameObjectAddon.WorldEffectID = result.Read<uint>(5);
// checks // checks
if (gameObjectAddon.faction != 0 && !CliDB.FactionTemplateStorage.ContainsKey(gameObjectAddon.faction)) if (gameObjectAddon.faction != 0 && !CliDB.FactionTemplateStorage.ContainsKey(gameObjectAddon.faction))
Log.outError(LogFilter.Sql, "GameObject (Entry: {0}) has invalid faction ({1}) defined in `gameobject_template_addon`.", entry, gameObjectAddon.faction); Log.outError(LogFilter.Sql, $"GameObject (Entry: {entry}) has invalid faction ({gameObjectAddon.faction}) defined in `gameobject_template_addon`.");
if (gameObjectAddon.maxgold > 0) if (gameObjectAddon.maxgold > 0)
{ {
@@ -3842,13 +3843,18 @@ namespace Game
case GameObjectTypes.FishingHole: case GameObjectTypes.FishingHole:
break; break;
default: default:
Log.outError(LogFilter.Sql, "GameObject (Entry {0} GoType: {1}) cannot be looted but has maxgold set in `gameobject_template_addon`.", entry, got.type); Log.outError(LogFilter.Sql, $"GameObject (Entry {entry} GoType: {got.type}) cannot be looted but has maxgold set in `gameobject_template_addon`.");
break; break;
} }
} }
_gameObjectTemplateAddonStore[entry] = gameObjectAddon; if (gameObjectAddon.WorldEffectID != 0 && !CliDB.WorldEffectStorage.ContainsKey(gameObjectAddon.WorldEffectID))
{
Log.outError(LogFilter.Sql, $"GameObject (Entry: {entry}) has invalid WorldEffectID ({gameObjectAddon.WorldEffectID}) defined in `gameobject_template_addon`, set to 0.");
gameObjectAddon.WorldEffectID = 0;
}
_gameObjectTemplateAddonStore[entry] = gameObjectAddon;
++count; ++count;
} }
while (result.NextRow()); while (result.NextRow());
@@ -4062,8 +4068,8 @@ namespace Game
_gameObjectAddonStorage.Clear(); _gameObjectAddonStorage.Clear();
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6 7
SQLResult result = DB.World.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue FROM gameobject_addon"); SQLResult result = DB.World.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue, WorldEffectID FROM gameobject_addon");
if (result.IsEmpty()) if (result.IsEmpty())
{ {
@@ -4079,7 +4085,7 @@ namespace Game
GameObjectData goData = GetGOData(guid); GameObjectData goData = GetGOData(guid);
if (goData == null) if (goData == null)
{ {
Log.outError(LogFilter.Sql, "GameObject (GUID: {0}) does not exist but has a record in `gameobject_addon`", guid); Log.outError(LogFilter.Sql, $"GameObject (GUID: {guid}) does not exist but has a record in `gameobject_addon`");
continue; continue;
} }
@@ -4087,32 +4093,39 @@ namespace Game
gameObjectAddon.ParentRotation = new Quaternion(result.Read<float>(1), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4)); gameObjectAddon.ParentRotation = new Quaternion(result.Read<float>(1), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4));
gameObjectAddon.invisibilityType = (InvisibilityType)result.Read<byte>(5); gameObjectAddon.invisibilityType = (InvisibilityType)result.Read<byte>(5);
gameObjectAddon.invisibilityValue = result.Read<uint>(6); gameObjectAddon.invisibilityValue = result.Read<uint>(6);
gameObjectAddon.WorldEffectID = result.Read<uint>(7);
if (gameObjectAddon.invisibilityType >= InvisibilityType.Max) if (gameObjectAddon.invisibilityType >= InvisibilityType.Max)
{ {
Log.outError(LogFilter.Sql, "GameObject (GUID: {0}) has invalid InvisibilityType in `gameobject_addon`, disabled invisibility", guid); Log.outError(LogFilter.Sql, $"GameObject (GUID: {guid}) has invalid InvisibilityType in `gameobject_addon`, disabled invisibility");
gameObjectAddon.invisibilityType = InvisibilityType.General; gameObjectAddon.invisibilityType = InvisibilityType.General;
gameObjectAddon.invisibilityValue = 0; gameObjectAddon.invisibilityValue = 0;
} }
if (gameObjectAddon.invisibilityType != 0 && gameObjectAddon.invisibilityValue == 0) if (gameObjectAddon.invisibilityType != 0 && gameObjectAddon.invisibilityValue == 0)
{ {
Log.outError(LogFilter.Sql, "GameObject (GUID: {0}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1", guid); Log.outError(LogFilter.Sql, $"GameObject (GUID: {guid}) has InvisibilityType set but has no InvisibilityValue in `gameobject_addon`, set to 1");
gameObjectAddon.invisibilityValue = 1; gameObjectAddon.invisibilityValue = 1;
} }
if (!gameObjectAddon.ParentRotation.isUnit()) if (!gameObjectAddon.ParentRotation.isUnit())
{ {
Log.outError(LogFilter.Sql, "GameObject (GUID: {0}) has invalid parent rotation in `gameobject_addon`, set to default", guid); Log.outError(LogFilter.Sql, $"GameObject (GUID: {guid}) has invalid parent rotation in `gameobject_addon`, set to default");
gameObjectAddon.ParentRotation = Quaternion.WAxis; gameObjectAddon.ParentRotation = Quaternion.WAxis;
} }
if (gameObjectAddon.WorldEffectID != 0 && !CliDB.WorldEffectStorage.ContainsKey(gameObjectAddon.WorldEffectID))
{
Log.outError(LogFilter.Sql, $"GameObject (GUID: {guid}) has invalid WorldEffectID ({gameObjectAddon.WorldEffectID}) in `gameobject_addon`, set to 0.");
gameObjectAddon.WorldEffectID = 0;
}
_gameObjectAddonStorage[guid] = gameObjectAddon; _gameObjectAddonStorage[guid] = gameObjectAddon;
++count; ++count;
} }
while (result.NextRow()); while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} gameobject addons in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime)); Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} gameobject addons in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
} }
public void LoadGameObjectQuestItems() public void LoadGameObjectQuestItems()
{ {