diff --git a/src/game/Object/Object.cpp b/src/game/Object/Object.cpp index 566839f93..b64ebaac4 100644 --- a/src/game/Object/Object.cpp +++ b/src/game/Object/Object.cpp @@ -829,6 +829,14 @@ void Object::SetUInt32Value(uint16 index, uint32 value) } } +void Object::UpdateUInt32Value(uint16 index, uint32 value) +{ + MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true)); + + m_uint32Values[index] = value; + m_changedValues[index] = true; +} + void Object::SetUInt64Value(uint16 index, const uint64& value) { MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); @@ -1757,6 +1765,28 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa return pCreature; } +GameObject* WorldObject::SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime) +{ + GameObject* pGameObj = new GameObject; + + Map *map = GetMap(); + + if (!map) + return NULL; + + if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), id, map, x, y, z, angle)) + { + delete pGameObj; + return NULL; + } + + pGameObj->SetRespawnTime(despwtime / IN_MILLISECONDS); + + map->Add(pGameObj); + + return pGameObj; +} + // how much space should be left in front of/ behind a mob that already uses a space #define OCCUPY_POS_DEPTH_FACTOR 1.8f diff --git a/src/game/Object/Object.h b/src/game/Object/Object.h index b93733c3f..1b77ed8ee 100644 --- a/src/game/Object/Object.h +++ b/src/game/Object/Object.h @@ -243,7 +243,8 @@ class Object DynamicObject const* ToDynObject() const { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast(this); else return NULL; } void SetInt32Value(uint16 index, int32 value); - void SetUInt32Value(uint16 index, uint32 value); + void SetUInt32Value(uint16 index, uint32 value); + void UpdateUInt32Value(uint16 index, uint32 value); void SetUInt64Value(uint16 index, const uint64& value); void SetFloatValue(uint16 index, float value); void SetByteValue(uint16 index, uint8 offset, uint8 value); @@ -634,6 +635,7 @@ class WorldObject : public Object void BuildUpdateData(UpdateDataMapType&) override; Creature* SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject = false); + GameObject* SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime); bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); } void SetActiveObjectState(bool active); diff --git a/src/game/Object/ObjectMgr.h b/src/game/Object/ObjectMgr.h index 5ad31a149..65cfe3840 100644 --- a/src/game/Object/ObjectMgr.h +++ b/src/game/Object/ObjectMgr.h @@ -1064,6 +1064,12 @@ class ObjectMgr bool RemoveVendorItem(uint32 entry, uint32 item, uint8 type); bool IsVendorItemValid(bool isTemplate, char const* tableName, uint32 vendor_entry, uint32 item, uint8 type, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, uint16 conditionId, Player* pl = NULL, std::set* skip_vendors = NULL) const; + static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value) + { + if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) + value = data[loc_idx]; + } + int GetOrNewIndexForLocale(LocaleConstant loc); SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 0f6746567..0d3363d74 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -7199,7 +7199,7 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM if (spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000000002)) && spellProto->SpellIconID == 12) { // Glyph of Fire Blast - if (pVictim->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) || pVictim->isInRoots()) + if (pVictim->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) || pVictim->IsInRoots()) if (Aura* aura = GetAura(56369, EFFECT_INDEX_0)) crit_chance += aura->GetModifier()->m_amount; } diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index cdbf87baa..e29446f6f 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -1681,6 +1681,9 @@ class Unit : public WorldObject * \see GetUInt32Value */ uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } + + bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); } + /** * Gets the percent of the health. The formula: (GetHealth() * 100) / GetMaxHealth() * @return the current percent of the health @@ -2203,12 +2206,56 @@ class Unit : public WorldObject } bool HasAuraOfDifficulty(uint32 spellId) const; + /** + * This is overridden in \ref Player::HasSpell, \ref Creature::HasSpell and \ref Pet::HasSpell + * @return false in this implementation + */ virtual bool HasSpell(uint32 /*spellID*/) const { return false; } + /** + * Check is this \ref Unit has a stealth modified applied + * @return true if this \ref Unit has the \ref AuraType \ref AuraType::SPELL_AURA_MOD_STEALTH + * applied, false otherwise + * \see Modifier + * \see Unit::HasAuraType + * \see AuraType + */ bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); } + /** + * Check if this \ref Unit has a invisibility \ref Aura modifier applied. + * @return true if this \ref Unit has the \ref AuraType + * \ref AuraType::SPELL_AURA_MOD_INVISIBILITY applied, false otherwise + * \see Modifier + * \see Unit::HasAuraType + * \see AuraType + */ bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); } + /** + * Check if this \ref Unit has a fear \ref Aura modifier applied. Ie, is it feared? + * @return true if this \ref Unit has the \ref AuraType \ref AuraType::SPELL_AURA_MOD_FEAR + * applied, false otherwise + * \see Modifier + * \see Unit::HasAuraType + * \see AuraType + */ bool isFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); } - bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); } + /** + * Check if this \ref Unit has a rooting \ref Aura modifier applied. Ie, is it stuck in + * some way? + * @return true if this \ref Unit has the \ref AuraType \ref AuraType::SPELL_AURA_MOD_ROOT + * applied, false otherwise + * \see Modifier + * \see Unit::HasAuraType + * \see AuraType + */ + bool IsInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); } + /** + * Is this \ref Unit polymorphed? + * @return true if this \ref Unit is polymorphed, false otherwise + * \see GetSpellSpecific + * \see Unit::GetTransform + * \todo Move the implementation to .h file exactly as the earlier ones? + */ bool IsPolymorphed() const; bool IsFrozen() const; diff --git a/src/game/WorldHandlers/GridNotifiers.h b/src/game/WorldHandlers/GridNotifiers.h index 773e907ea..3e4c07259 100644 --- a/src/game/WorldHandlers/GridNotifiers.h +++ b/src/game/WorldHandlers/GridNotifiers.h @@ -221,6 +221,23 @@ namespace MaNGOS template void Visit(GridRefManager &) {} }; + template + struct WorldObjectLastSearcher + { + WorldObject*& i_object; + Check& i_check; + + WorldObjectLastSearcher(WorldObject* & result, Check& check) : i_object(result), i_check(check) {} + + void Visit(PlayerMapType& m); + void Visit(CreatureMapType& m); + void Visit(CorpseMapType& m); + void Visit(GameObjectMapType& m); + void Visit(DynamicObjectMapType& m); + + template void Visit(GridRefManager&) {} + }; + template struct WorldObjectListSearcher { diff --git a/src/modules/Eluna/UnitMethods.h b/src/modules/Eluna/UnitMethods.h index 5f59326ff..8c83117f9 100644 --- a/src/modules/Eluna/UnitMethods.h +++ b/src/modules/Eluna/UnitMethods.h @@ -55,10 +55,10 @@ namespace LuaUnit int IsRooted(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef TRINITY - Eluna::Push(L, unit->isInRoots() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); + Eluna::Push(L, unit->IsInRoots() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); #endif #ifdef CMANGOS - Eluna::Push(L, unit->isInRoots() || unit->IsRooted()); + Eluna::Push(L, unit->IsInRoots() || unit->IsRooted()); #endif #ifdef MANGOS Eluna::Push(L, unit->IsInRoots() || unit->IsRooted());