From 4e130dcdfdd30b84fb5e0b0531c817c7b6c64ff9 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 8 Jun 2009 17:25:02 -0500 Subject: [7980] Implement item use target requirements store and check (new table `item_required_target`). Author: NoFantasy Signed-off-by: VladimirMangos * Also implement this table reload * Static Spell::SendCastResult function for call not from spell code. Can be also used in scripts where need send explicitly spell cast error to client. --HG-- branch : trunk --- src/game/ObjectMgr.cpp | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'src/game/ObjectMgr.cpp') diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 8c0e5d6e1bd..350bf5d3a15 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -2117,6 +2117,106 @@ void ObjectMgr::LoadItemPrototypes() } } +void ObjectMgr::LoadItemRequiredTarget() +{ + m_ItemRequiredTarget.clear(); // needed for reload case + + uint32 count = 0; + + QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM item_required_target"); + + if (!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded 0 ItemRequiredTarget. DB table `item_required_target` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 uiItemId = fields[0].GetUInt32(); + uint32 uiType = fields[1].GetUInt32(); + uint32 uiTargetEntry = fields[2].GetUInt32(); + + ItemPrototype const* pItemProto = sItemStorage.LookupEntry(uiItemId); + + if (!pItemProto) + { + sLog.outErrorDb("Table `item_required_target`: Entry %u listed for TargetEntry %u does not exist in `item_template`.",uiItemId,uiTargetEntry); + continue; + } + + bool bIsItemSpellValid = false; + + for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + { + if (SpellEntry const* pSpellInfo = sSpellStore.LookupEntry(pItemProto->Spells[i].SpellId)) + { + if (pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE || + pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE) + { + SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(pSpellInfo->Id); + SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(pSpellInfo->Id); + + if (lower != upper) + break; + + if (pSpellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY || + pSpellInfo->EffectImplicitTargetB[i] == TARGET_UNIT_TARGET_ENEMY || + pSpellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ANY || + pSpellInfo->EffectImplicitTargetB[i] == TARGET_UNIT_TARGET_ANY) + { + bIsItemSpellValid = true; + break; + } + } + } + } + + if (!bIsItemSpellValid) + { + sLog.outErrorDb("Table `item_required_target`: Spell used by item %u does not have implicit target TARGET_CHAIN_DAMAGE(6), TARGET_DUELVSPLAYER(25), already listed in `spell_script_target` or doesn't have item spelltrigger.",uiItemId); + continue; + } + + if (!uiType || uiType > MAX_ITEM_REQ_TARGET_TYPE) + { + sLog.outErrorDb("Table `item_required_target`: Type %u for TargetEntry %u is incorrect.",uiType,uiTargetEntry); + continue; + } + + if (!uiTargetEntry) + { + sLog.outErrorDb("Table `item_required_target`: TargetEntry == 0 for Type (%u).",uiType); + continue; + } + + if (!sCreatureStorage.LookupEntry(uiTargetEntry)) + { + sLog.outErrorDb("Table `item_required_target`: creature template entry %u does not exist.",uiTargetEntry); + continue; + } + + m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId,ItemRequiredTarget(ItemRequiredTargetType(uiType),uiTargetEntry))); + + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString(">> Loaded %u Item required targets", count); +} + void ObjectMgr::LoadPetLevelInfo() { // Loading levels data -- cgit v1.2.3 From a8dbf8904c3004ad2135ff3f8fcc43490abc4e46 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 8 Jun 2009 23:43:25 -0500 Subject: *Correctly show spellclick flag for vehicles and creatures with info in spellclick table. --HG-- branch : trunk --- src/game/Level1.cpp | 2 +- src/game/ObjectMgr.cpp | 3 +++ src/game/Player.cpp | 4 ++++ src/game/SpellAuras.cpp | 13 ++++++------- src/game/SpellEffects.cpp | 4 +--- src/game/Unit.cpp | 1 - src/game/Vehicle.cpp | 10 +++++----- 7 files changed, 20 insertions(+), 17 deletions(-) (limited to 'src/game/ObjectMgr.cpp') diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 86a689e7383..f8acec049c2 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1524,7 +1524,7 @@ bool ChatHandler::HandleModifyASpeedCommand(const char* args) float ASpeed = (float)atof((char*)args); - if (ASpeed > 10 || ASpeed < 0.1) + if (ASpeed > 50 || ASpeed < 0) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 350bf5d3a15..38ba9c33a6c 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -6467,6 +6467,9 @@ void ObjectMgr::LoadNPCSpellClickSpells() continue; } + if(!(cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK)) + const_cast(cInfo)->npcflag |= UNIT_NPC_FLAG_SPELLCLICK; + uint32 spellid = fields[1].GetUInt32(); SpellEntry const *spellinfo = sSpellStore.LookupEntry(spellid); if (!spellinfo) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index d647768d3e0..7099b7e3945 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17437,6 +17437,10 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc // stop combat at start taxi flight if any CombatStop(); + StopCastingCharm(); + StopCastingBindSight(); + ExitVehicle(); + // stop trade (client cancel trade at taxi map open but cheating tools can be used for reopen it) TradeCancel(true); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 3e6c1e3ff41..43f004d7701 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3879,10 +3879,9 @@ void AuraEffect::HandleAuraModDisarm(bool apply, bool Real, bool /*changeAmount* AuraType type = AuraType(GetAuraName()); //Prevent handling aura twice - if(apply && m_target->GetAurasByType(type).size()>1) - return; - if(!apply && m_target->HasAuraType(type)) + if(apply ? m_target->GetAurasByType(type).size() > 1 : m_target->HasAuraType(type)) return; + uint32 field, flag, slot; WeaponAttackType attType; switch (type) @@ -3905,6 +3904,8 @@ void AuraEffect::HandleAuraModDisarm(bool apply, bool Real, bool /*changeAmount* slot=EQUIPMENT_SLOT_RANGED; attType=RANGED_ATTACK; break; + default: + return; } if(apply) m_target->SetFlag(field, flag); @@ -3913,10 +3914,8 @@ void AuraEffect::HandleAuraModDisarm(bool apply, bool Real, bool /*changeAmount* if (m_target->GetTypeId() == TYPEID_PLAYER) { - Item *pItem = ((Player*)m_target)->GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); - if(!pItem ) - return; - ((Player*)m_target)->_ApplyItemMods(pItem, slot, !apply); + if(Item *pItem = ((Player*)m_target)->GetItemByPos( INVENTORY_SLOT_BAG_0, slot )) + ((Player*)m_target)->_ApplyItemMods(pItem, slot, !apply); } else if (((Creature*)m_target)->GetCurrentEquipmentId()) m_target->UpdateDamagePhysical(attType); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 0c8a4eee292..e26c8c25827 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3393,10 +3393,8 @@ void Spell::EffectSummonType(uint32 i) vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); if(damage) - { m_caster->CastSpell(vehicle, damage, true); - m_caster->EnterVehicle(vehicle); - } + m_caster->EnterVehicle(vehicle); break; } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index bc2f6b0b540..156a22a4b33 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -13618,7 +13618,6 @@ void Unit::SetCharmedBy(Unit* charmer, CharmType type) if(GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->AI()->OnCharmed(true); - GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); } else diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 3efe735a5b5..5197e799104 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -24,7 +24,6 @@ #include "Util.h" #include "WorldPacket.h" -#include "Chat.h" #include "CreatureAI.h" #include "ZoneScript.h" @@ -85,6 +84,11 @@ void Vehicle::setDeathState(DeathState s) // overwrite vir } RemoveAllPassengers(); } + else if(s == JUST_ALIVED) + { + if(m_usableSeatNum) + SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); + } Creature::setDeathState(s); } @@ -244,13 +248,9 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) GetPositionZ() + unit->m_movementInfo.t_z, GetOrientation()); - unit->GetMotionMaster()->MoveIdle(MOTION_SLOT_IDLE); - WorldPacket data; if(unit->GetTypeId() == TYPEID_PLAYER) { - //ChatHandler(player).PSendSysMessage("Enter seat %u %u", veSeat->m_ID, seat->first); - if(seat->first == 0 && seat->second.seatInfo->IsUsable()) // not right SetCharmedBy(unit, CHARM_TYPE_VEHICLE); -- cgit v1.2.3