From 2f02dc7642b4ad2a4a71b7a9d58f3e4183849200 Mon Sep 17 00:00:00 2001 From: Lightguard Date: Mon, 2 Mar 2009 02:43:40 +0300 Subject: [PATCH] [7368] Implement unequip unexpected offhand weapons at talent reset (mostly for warror talent case). Signed-off-by: VladimirMangos Implemented OffhandCheckAtTalentsReset option for unequip at zone change (default) and at talent reset itself (can be enabled). --- src/game/Player.cpp | 25 ++++++++++++++++++++++--- src/game/World.cpp | 2 ++ src/game/World.h | 1 + src/mangosd/mangosd.conf.dist.in | 6 ++++++ src/shared/revision_nr.h | 2 +- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index a548b102a..e8e516256 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3342,6 +3342,13 @@ bool Player::resetTalents(bool no_cost) //FIXME: remove pet before or after unlearn spells? for now after unlearn to allow removing of talent related, pet affecting auras RemovePet(NULL,PET_SAVE_NOT_IN_SLOT, true); + if(m_canTitanGrip) + { + m_canTitanGrip = false; + if(sWorld.getConfig(CONFIG_OFFHAND_CHECK_AT_TALENTS_RESET)) + AutoUnequipOffhandIfNeed(); + } + return true; } @@ -6417,6 +6424,9 @@ void Player::UpdateZone(uint32 newZone) if(isAlive()) DestroyZoneLimitedItem( true, newZone ); + // check some item equip limitations (in result lost CanTitanGrip at talent reset, for example) + AutoUnequipOffhandIfNeed(); + // recent client version not send leave/join channel packets for built-in local channels UpdateLocalChannels( newZone ); @@ -18806,8 +18816,8 @@ void Player::AutoUnequipOffhandIfNeed() if(!offItem) return; - // need unequip for 2h-weapon without TitanGrip - if (!IsTwoHandUsed()) + // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) + if (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed())) return; ItemPosCountVec off_dest; @@ -18819,7 +18829,16 @@ void Player::AutoUnequipOffhandIfNeed() } else { - sLog.outError("Player::EquipItem: Can's store offhand item at 2hand item equip for player (GUID: %u).",GetGUIDLow()); + MailItemsInfo mi; + mi.AddItem(offItem->GetGUIDLow(), offItem->GetEntry(), offItem); + MoveItemFromInventory(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true); + CharacterDatabase.BeginTransaction(); + offItem->DeleteFromInventoryDB(); // deletes item from character's inventory + offItem->SaveToDB(); // recursive and not have transaction guard into self, item not in inventory and can be save standalone + CharacterDatabase.CommitTransaction(); + + std::string subject = GetSession()->GetMangosString(LANG_NOT_EQUIPPED_ITEM); + WorldSession::SendMailTo(this, MAIL_NORMAL, MAIL_STATIONERY_GM, GetGUIDLow(), GetGUIDLow(), subject, 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); } } diff --git a/src/game/World.cpp b/src/game/World.cpp index 1e8aa787c..0c7d222f9 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -940,6 +940,8 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_ARENA_SEASON_ID] = sConfig.GetIntDefault ("Arena.ArenaSeason.ID", 1); m_configs[CONFIG_ARENA_SEASON_IN_PROGRESS] = sConfig.GetBoolDefault("Arena.ArenaSeason.InProgress", true); + m_configs[CONFIG_OFFHAND_CHECK_AT_TALENTS_RESET] = sConfig.GetBoolDefault("OffhandCheckAtTalentsReset", false); + m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetIntDefault("InstantLogout", SEC_MODERATOR); m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); diff --git a/src/game/World.h b/src/game/World.h index 9c908c127..55c0649ae 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -195,6 +195,7 @@ enum WorldConfigs CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE, CONFIG_ARENA_SEASON_ID, CONFIG_ARENA_SEASON_IN_PROGRESS, + CONFIG_OFFHAND_CHECK_AT_TALENTS_RESET, CONFIG_VALUE_COUNT }; diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in index 8a333823f..268d81457 100644 --- a/src/mangosd/mangosd.conf.dist.in +++ b/src/mangosd/mangosd.conf.dist.in @@ -546,6 +546,11 @@ LogColors = "" # Default: 0 - no skilups # 1 - skilups possible # +# OffhandCheckAtTalentsReset +# Talent reset can change offhand weapon restrictions for equip slots. +# Default: 0 - recheck offhand slot weapon only at zone update +# 1 - recheck offhand slot weapon at talent reset also +# # Event.Announce # Default: 0 (false) # 1 (true) @@ -600,6 +605,7 @@ MaxGroupXPDistance = 74 MailDeliveryDelay = 3600 SkillChance.Prospecting = 0 SkillChance.Milling = 0 +OffhandCheckAtTalentsReset = 0 Event.Announce = 0 BeepAtStart = 1 Motd = "Welcome to the Massive Network Game Object Server." diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 926ee3485..e7c5ed337 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 "7367" + #define REVISION_NR "7368" #endif // __REVISION_NR_H__