Misc updates

This commit is contained in:
hondacrx
2021-06-23 12:01:28 -04:00
parent b70086db18
commit 9fd7c12094
2 changed files with 48 additions and 59 deletions
+26 -26
View File
@@ -216,35 +216,35 @@ namespace Game.Chat
var its = Global.ObjectMgr.GetItemTemplates();
foreach (var template in its)
{
if (template.Value.GetItemSet() == itemSetId)
if (template.Value.GetItemSet() != itemSetId)
continue;
found = true;
List<ItemPosCount> dest = new();
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, template.Value.GetId(), 1);
if (msg == InventoryResult.Ok)
{
found = true;
List<ItemPosCount> dest = new();
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, template.Value.GetId(), 1);
if (msg == InventoryResult.Ok)
List<uint> bonusListIDsForItem = new(bonusListIDs); // copy, bonuses for each depending on context might be different for each item
if (itemContext != ItemContext.None && itemContext < ItemContext.Max)
{
List<uint> bonusListIDsForItem = new(bonusListIDs); // copy, bonuses for each depending on context might be different for each item
if (itemContext != ItemContext.None && itemContext < ItemContext.Max)
{
var contextBonuses = Global.DB2Mgr.GetDefaultItemBonusTree(template.Value.GetId(), itemContext);
bonusListIDsForItem.AddRange(contextBonuses);
}
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, itemContext, bonusListIDsForItem);
// remove binding (let GM give it to another player later)
if (player == playerTarget)
item.SetBinding(false);
player.SendNewItem(item, 1, false, true);
if (player != playerTarget)
playerTarget.SendNewItem(item, 1, true, false);
}
else
{
player.SendEquipError(msg, null, null, template.Value.GetId());
handler.SendSysMessage(CypherStrings.ItemCannotCreate, template.Value.GetId(), 1);
var contextBonuses = Global.DB2Mgr.GetDefaultItemBonusTree(template.Value.GetId(), itemContext);
bonusListIDsForItem.AddRange(contextBonuses);
}
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, itemContext, bonusListIDsForItem);
// remove binding (let GM give it to another player later)
if (player == playerTarget)
item.SetBinding(false);
player.SendNewItem(item, 1, false, true);
if (player != playerTarget)
playerTarget.SendNewItem(item, 1, true, false);
}
else
{
player.SendEquipError(msg, null, null, template.Value.GetId());
handler.SendSysMessage(CypherStrings.ItemCannotCreate, template.Value.GetId(), 1);
}
}
+22 -33
View File
@@ -3668,7 +3668,6 @@ namespace Game
}
else
{
uint count = 0;
do
{
uint entry = result.Read<uint>(0);
@@ -3817,11 +3816,10 @@ namespace Game
}
_gameObjectTemplateStorage[entry] = got;
++count;
}
while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} game object templates in {1} ms", count, Time.GetMSTimeDiffToNow(time));
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} game object templates in {1} ms", _gameObjectTemplateStorage.Count, Time.GetMSTimeDiffToNow(time));
}
}
public void LoadGameObjectTemplateAddons()
@@ -4239,48 +4237,43 @@ namespace Game
uint count = 0;
// collect GO entries for GO that must activated
foreach (var go in GetGameObjectTemplates())
foreach (var pair in GetGameObjectTemplates())
{
switch (go.Value.type)
switch (pair.Value.type)
{
case GameObjectTypes.QuestGiver:
_gameObjectForQuestStorage.Add(go.Value.entry);
++count;
break;
case GameObjectTypes.Chest:
{
// scan GO chest with loot including quest items
uint loot_id = (go.Value.GetLootId());
uint lootId = pair.Value.GetLootId();
// find quest loot for GO
if (go.Value.Chest.questID != 0 || Loots.LootStorage.Gameobject.HaveQuestLootFor(loot_id))
{
_gameObjectForQuestStorage.Add(go.Value.entry);
++count;
}
break;
if (pair.Value.Chest.questID != 0 || Loots.LootStorage.Gameobject.HaveQuestLootFor(lootId))
break;
continue;
}
case GameObjectTypes.Generic:
{
if (go.Value.Generic.questID > 0) //quests objects
{
_gameObjectForQuestStorage.Add(go.Value.entry);
++count;
}
break;
if (pair.Value.Generic.questID > 0) //quests objects
break;
continue;
}
case GameObjectTypes.Goober:
{
if (go.Value.Goober.questID > 0) //quests objects
{
_gameObjectForQuestStorage.Add(go.Value.entry);
++count;
}
break;
if (pair.Value.Goober.questID > 0) //quests objects
break;
continue;
}
default:
break;
continue;
}
_gameObjectForQuestStorage.Add(pair.Value.entry);
++count;
}
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} GameObjects for quests in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
@@ -7308,8 +7301,7 @@ namespace Game
if (qinfo.NextQuestInChain != 0)
{
var qNext = _questTemplates.LookupByKey(qinfo.NextQuestInChain);
if (qNext == null)
if (!_questTemplates.ContainsKey(qinfo.NextQuestInChain))
{
Log.outError(LogFilter.Sql, "Quest {0} has `NextQuestIdChain` = {1} but quest {2} does not exist, quest chain will not work.",
qinfo.Id, qinfo.NextQuestInChain, qinfo.NextQuestInChain);
@@ -7567,8 +7559,6 @@ namespace Game
_questPOIStorage.Clear(); // need for reload case
uint count = 0;
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
SQLResult result = DB.World.Query("SELECT QuestID, BlobIndex, Idx1, ObjectiveIndex, QuestObjectiveID, QuestObjectID, MapID, UiMapID, Priority, Flags, WorldEffectID, PlayerConditionID, NavigationPlayerConditionID, SpawnTrackingID, AlwaysAllowMergingBlobs FROM quest_poi order by QuestID, Idx1");
if (result.IsEmpty())
@@ -7632,7 +7622,6 @@ namespace Game
poiData.QuestID = questID;
poiData.Blobs.Add(new QuestPOIBlobData(blobIndex, objectiveIndex, questObjectiveID, questObjectID, mapID, uiMapId, priority, flags,
worldEffectID, playerConditionID, navigationPlayerConditionID, spawnTrackingID, points, alwaysAllowMergingBlobs));
++count;
continue;
}
}
@@ -7640,7 +7629,7 @@ namespace Game
} while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} quest POI definitions in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} quest POI definitions in {1} ms", _questPOIStorage.Count, Time.GetMSTimeDiffToNow(oldMSTime));
}
public void LoadQuestAreaTriggers()
{