GameObject::~GameObject() { sEventMgr.RemoveEvents(this); if(m_ritualmembers) delete[] m_ritualmembers; uint32 guid = GetUInt32Value(OBJECT_FIELD_CREATED_BY); if(guid) { Player *plr = objmgr.GetPlayer(guid); if(plr && plr->GetSummonedObject() == this) plr->SetSummonedObject(NULL); if(plr == m_summoner) m_summoner = 0; } if(m_respawnCell!=NULL) m_respawnCell->_respawnObjects.erase(this); if (m_summonedGo && m_summoner) for(int i = 0; i < 4; i++) if (m_summoner->m_ObjectSlots[i] == GetUIdFromGUID()) m_summoner->m_ObjectSlots[i] = 0; if( m_battleground != NULL && m_battleground->GetType() == BATTLEGROUND_ARATHI_BASIN ) { if( bannerslot >= 0 && static_cast<ArathiBasin*>(m_battleground)->m_controlPoints[bannerslot] == this ) static_cast<ArathiBasin*>(m_battleground)->m_controlPoints[bannerslot] = NULL; if( bannerauraslot >= 0 && static_cast<ArathiBasin*>(m_battleground)->m_controlPointAuras[bannerauraslot] == this ) static_cast<ArathiBasin*>(m_battleground)->m_controlPointAuras[bannerauraslot] = NULL; } }
void GameObject::OnRemoveInRangeObject(Object* pObj) { Object::OnRemoveInRangeObject(pObj); if(m_summonedGo && m_summoner == pObj) { for(int i = 0; i < 4; i++) if (m_summoner->m_ObjectSlots[i] == GetUIdFromGUID()) m_summoner->m_ObjectSlots[i] = 0; m_summoner = 0; ExpireAndDelete(); } }
void Transporter::AddNPC(uint32 Entry, float offsetX, float offsetY, float offsetZ, float offsetO) { uint32 guid; m_transportGuidGen.Acquire(); guid = ++m_transportGuidMax; m_transportGuidGen.Release(); CreatureInfo * inf = CreatureNameStorage.LookupEntry(Entry); CreatureProto * proto = CreatureProtoStorage.LookupEntry(Entry); if(inf==NULL||proto==NULL) return; Creature * pCreature = new Creature((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | guid); pCreature->Load(proto, m_position.x, m_position.y, m_position.z); pCreature->m_transportPosition = new LocationVector(offsetX, offsetY, offsetZ, offsetO); pCreature->m_transportGuid = GetUIdFromGUID(); m_npcs.insert(make_pair(guid,pCreature)); }
GameObject::~GameObject() { if(m_ritualmembers) delete[] m_ritualmembers; uint32 guid = GetUInt32Value(OBJECT_FIELD_CREATED_BY); if(guid) { Player* plr = objmgr.GetPlayer(guid); if(plr && plr->GetSummonedObject() == TO_OBJECT(this) ) plr->SetSummonedObject(NULL); if(plr == m_summoner) m_summoner = NULL; } if(m_respawnCell != NULL) m_respawnCell->_respawnObjects.erase( TO_OBJECT(this) ); if (m_summonedGo && m_summoner) for(int i = 0; i < 4; i++) if (m_summoner->m_ObjectSlots[i] == GetUIdFromGUID()) m_summoner->m_ObjectSlots[i] = 0; if( m_battleground != NULL ) { if( m_battleground->GetType() == BATTLEGROUND_ARATHI_BASIN ) { if( bannerslot >= 0 && TO_ARATHIBASIN(m_battleground)->m_controlPoints[bannerslot] == TO_GAMEOBJECT(this) ) TO_ARATHIBASIN(m_battleground)->m_controlPoints[bannerslot] = NULL; if( bannerauraslot >= 0 && TO_ARATHIBASIN(m_battleground)->m_controlPointAuras[bannerauraslot] == TO_GAMEOBJECT(this) ) TO_ARATHIBASIN(m_battleground)->m_controlPointAuras[bannerauraslot] = NULL; } m_battleground = NULL; } }
void Pet::CreateAsSummon(uint32 entry, CreatureInfo *ci, Creature* created_from_creature, Unit* owner, SpellEntry* created_by_spell, uint32 type, uint32 expiretime) { if(ci == NULL) return; SetIsPet(true); m_OwnerGuid = owner->GetGUID(); m_Owner = TO_PLAYER(owner); m_OwnerGuid = m_Owner->GetGUID(); creature_info = ci; myFamily = dbcCreatureFamily.LookupEntry(creature_info->Family); //m_name = objmgr.GetCreatureFamilyName(myFamily->ID); if( myFamily->name == NULL ) m_name = "Pet"; else m_name.assign( myFamily->name ); // Create ourself Create(m_name.c_str(), owner->GetMapId(), owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation()); SetUInt32Value(OBJECT_FIELD_ENTRY, entry); SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // better set this one // Fields common to both lock summons and pets uint32 level = (m_Owner->GetUInt32Value( UNIT_FIELD_LEVEL ) - 5); if( type & 0x2 && created_from_creature != NULL && created_from_creature->getLevel() > level) { level = created_from_creature->getLevel(); } SetUInt32Value(UNIT_FIELD_LEVEL, level); SetUInt32Value(UNIT_FIELD_DISPLAYID, ci->Male_DisplayID); SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, ci->Male_DisplayID); SetSummonedByGUID(owner->GetGUID()); SetCreatedByGUID(owner->GetGUID()); if(type & 0x1 && created_by_spell != NULL) SetUInt64Value(UNIT_CREATED_BY_SPELL, created_by_spell->Id); if(type & 0x1 || created_from_creature == NULL) { Summon = true; SetUInt32Value(UNIT_FIELD_BYTES_0, 2048 | (0 << 24)); SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 2000); SetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME, 2000); SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.5f); SetFloatValue(UNIT_FIELD_COMBATREACH, 0.75f); SetUInt32Value(UNIT_FIELD_BYTES_2, (0x01 | (0x2 << 24))); SetUInt32Value(UNIT_FIELD_PETNUMBER, GetUIdFromGUID()); SetPowerType(POWER_TYPE_MANA); if(entry == WATER_ELEMENTAL) m_name = "Water Elemental"; else if( entry == 19668) m_name = "Shadowfiend"; else m_name = sWorld.GenerateName(); } else { SetUInt32Value(UNIT_FIELD_BYTES_0, 2048 | (0 << 24)); SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 2000); SetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME, 2000); // Supalosa: 2.00 normalized attack speed // hacks D: allow correct creation of hunter pets via gm command if(created_from_creature == this) { SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.5f); SetFloatValue(UNIT_FIELD_COMBATREACH, 0.75f); } else { SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, created_from_creature->GetFloatValue(UNIT_FIELD_BOUNDINGRADIUS)); SetFloatValue(UNIT_FIELD_COMBATREACH, created_from_creature->GetFloatValue(UNIT_FIELD_COMBATREACH)); } // These need to be checked. SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED | UNIT_FLAG_COMBAT); // why combat ?? SetHappiness(PET_HAPPINESS_UPDATE_VALUE >> 1); // happiness SetUInt32Value(UNIT_FIELD_MAXPOWER5, 1000000); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, GetNextLevelXP(getLevel())); SetUInt32Value(UNIT_FIELD_BYTES_1, 0); // Focus SetUInt32Value(UNIT_FIELD_POWER3, 100); SetUInt32Value(UNIT_FIELD_MAXPOWER3, 100); // 0x3 -> Enable pet rename. SetUInt32Value(UNIT_FIELD_BYTES_2, 1 | (0x3 << 16)); // Change the power type to FOCUS SetPowerType(POWER_TYPE_FOCUS); // create our spells SetDefaultSpells(); InitTalentsForLevel(true); } // Apply stats. ApplyStatsForLevel(); BaseDamage[0]=GetFloatValue(UNIT_FIELD_MINDAMAGE); BaseDamage[1]=GetFloatValue(UNIT_FIELD_MAXDAMAGE); BaseOffhandDamage[0]=GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE); BaseOffhandDamage[1]=GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE); BaseRangedDamage[0]=GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE); BaseRangedDamage[1]=GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE); SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, owner->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE)); m_PartySpellsUpdateTimer = 0; m_PetNumber = TO_PLAYER(owner)->GeneratePetNumber(); SetUInt32Value(UNIT_FIELD_PETNUMBER, GetUIdFromGUID()); m_ExpireTime = expiretime; bExpires = m_ExpireTime > 0 ? true : false; if(!bExpires) { // Create PlayerPet struct (Rest done by UpdatePetInfo) PlayerPet *pp = new PlayerPet; pp->number = m_PetNumber; pp->stablestate = STABLE_STATE_ACTIVE; TO_PLAYER(owner)->AddPlayerPet(pp, pp->number); } //maybe we should use speed from the template we created the creature ? m_base_runSpeed = m_runSpeed = owner->m_base_runSpeed; //should we be able to keep up with master ? m_base_walkSpeed = m_walkSpeed = owner->m_base_walkSpeed; //should we be able to keep up with master ? InitializeMe(true); }