Exemple #1
0
void Pet::InitializeMe(bool first)
{
    // set up ai and shit
    
    GetAIInterface()->Init(this,AITYPE_PET,MOVEMENTTYPE_NONE,m_Owner);
    GetAIInterface()->SetUnitToFollow(m_Owner);
    GetAIInterface()->SetFollowDistance(3.0f);

    SetCreatureName(objmgr.GetCreatureName(GetEntry()));
    m_Owner->SetSummon(this);
    m_Owner->SetUInt64Value(UNIT_FIELD_SUMMON, this->GetGUID());
    SetUInt32Value(UNIT_FIELD_PETNUMBER, GetGUIDLow());
    SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, (uint32)time(NULL));

    bHasLoyalty = m_Owner->getClass() == HUNTER ? true : false;

    // Load our spells
    if(Summon)
    {
        SetDefaultSpells();
    }
    else
    {
        // Pull from database... :/
        QueryResult * query = sDatabase.Query("SELECT * FROM playerpetspells WHERE ownerguid=%u and petnumber=%u",
            m_Owner->GetGUIDLow(), m_PetNumber);
        if(query)
        {
            do 
            {
                Field * f = query->Fetch();
                SpellEntry* spell = sSpellStore.LookupEntry(f[2].GetUInt32());
                uint16 flags = f[3].GetUInt16();
                mSpells.insert ( make_pair( spell, flags ) );
            } while(query->NextRow());
        }
        delete query;
    }

    SetPetDiet();
    _setFaction();
    m_State = 1;        // dont set agro on spawn
    
    if(first)
    {
        // Set up default actionbar
        SetDefaultActionbar();
    }
    
    InitializeSpells();    
    AddToWorld();       // Add into the world

    sEventMgr.AddEvent(this, &Pet::Update, (uint32)100, EVENT_PET_UPDATE, 100, 0);

    // set to active
    if(!bExpires)
        UpdatePetInfo(false);
}
Exemple #2
0
void Pet::Rename(string NewName)
{
    m_name = NewName;
    // update petinfo
    UpdatePetInfo(false);

    // update timestamp to force a re-query
    SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
}
Exemple #3
0
void Pet::Remove(bool bSafeDelete, bool bUpdate)
{
    if(m_Owner)
    {
        // remove association with player
        m_Owner->SetUInt64Value(UNIT_FIELD_SUMMON, 0);

        if(bUpdate && !bExpires) UpdatePetInfo(true);
        m_Owner->SetSummon(NULL);
        SendNullSpellsToOwner();
    }

    if(bSafeDelete)
        sEventMgr.AddEvent(this, &Pet::PetSafeDelete, EVENT_CREATURE_SAFE_DELETE, 1, 1);
    else
        PetSafeDelete();
}
Exemple #4
0
void PetStash::RecvPetStashMessage(CNetworkMessage* istr)
{
	CUIManager* pUImanager = CUIManager::getSingleton();

	CUIPetStash* pStash = pUImanager->GetPetStash();
	CUIPetStashSelectEffect* pEffect = pUImanager->GetPetStashSelectEffect();

	pTypeBase* pBase = reinterpret_cast<pTypeBase*>(istr->GetBuffer());

	switch (pBase->subType)
	{
	case MSG_PET_STASH_LIST_UPDATE:
		{
			UpdateClient::PetStashList* pRecv = reinterpret_cast<UpdateClient::PetStashList*>(istr->GetBuffer());

			if (m_nPetCount != 0)
			{
				// 팻 창고 클리어
				ClearPetList();
				// UI 클리어
				if (pStash)
					pStash->ClearUI();
			}

			m_nProxyPetIndex = pRecv->proxyPetItemVIndex;
			m_nPetCount = pRecv->count;
						
			if ( m_nPetCount <= 0 )
			{
				// 펫 창고 클리어
				ClearPetList();
				// UI 클리어
				if (pStash)
					pStash->ClearUI();
			}
			else
			{
				PetStashData* pPetStashList = new PetStashData[m_nPetCount];
				memcpy( pPetStashList, &pRecv->petStashData[0], sizeof(PetStashData) * m_nPetCount );

				for (int i = 0; i < pRecv->count; i++)
				{
					m_vecPetStashList.push_back(&pPetStashList[i]);
				}
				UpdatePetInfo();
			}
		}
		break;

	case MSG_PET_STASH_PET_UPDATE:
		{
			UpdateClient::PetStashPetData* pRecv = reinterpret_cast<UpdateClient::PetStashPetData*>(istr->GetBuffer());

			PetStashData* pPetData = new PetStashData;
			memcpy( pPetData, &pRecv->petStashData, sizeof(PetStashData) );
			_UpdatePet(pPetData);

			SAFE_DELETE(pPetData);
		}
		break;

	case MSG_PET_STASH_TAKE:
		{
			ResponseClient::PetStashTake* pRecv = reinterpret_cast<ResponseClient::PetStashTake*>(istr->GetBuffer());

			if (pRecv->result != ERROR_PET_STASH_TAKE_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_TAKE_UPDATE:
		{
			UpdateClient::PetStashTake* pRecv = reinterpret_cast<UpdateClient::PetStashTake*>(istr->GetBuffer());
			DeletePet(pRecv->petItemVIndex);
		}
		break;

	case MSG_PET_STASH_KEEP:
		{
			ResponseClient::PetStashKeep* pRecv = reinterpret_cast<ResponseClient::PetStashKeep*>(istr->GetBuffer());

			if (pRecv->result != ERROR_PET_STASH_KEEP_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_KEEP_UPDATE:
		{
			UpdateClient::PetStashKeep* pRecv = reinterpret_cast<UpdateClient::PetStashKeep*>(istr->GetBuffer());

			PetStashData* pPetData = new PetStashData;
			memcpy( pPetData, &pRecv->petStashData, sizeof(PetStashData) );
			AddPet(pPetData);
		}
		break;

	case MSG_PET_STASH_PROXY:
		{
			ResponseClient::PetStashProxyReg* pRecv = reinterpret_cast<ResponseClient::PetStashProxyReg*>(istr->GetBuffer());
			
			if (pRecv->result != ERROR_PET_STASH_PROXY_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_PROXY_CANCEL:
		{
			ResponseClient::PetStashProxyCancel* pRecv = reinterpret_cast<ResponseClient::PetStashProxyCancel*>(istr->GetBuffer());

			if (pRecv->result != ERROR_PET_STASH_PROXY_CANCEL_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_EFFECT:
		{
			UpdateClient::PetStashEffect* pRecv = reinterpret_cast<UpdateClient::PetStashEffect*>(istr->GetBuffer());
			
			m_nEffectModelNo = pRecv->effectNo;
			
			if (pRecv->effectNo >= 0)
			{
				pUImanager->GetPetStashSelectEffect()->OpenPetStashSelectEffect();
			}
		}
		break;

	case MSG_PET_STASH_EFFECT_BY_INMAP: // 인맵, 기간만료시 제거
		{
			UpdateClient::PetStashEffectByInMap* pRecv = reinterpret_cast<UpdateClient::PetStashEffectByInMap*>(istr->GetBuffer());

			SetEffectModelNo(pRecv->effectNo);
		}
		break;

	case MSG_PET_STASH_EFFECT_BROAD_CAST:
		{
			UpdateClient::PetStashEffectBr* pRecv = reinterpret_cast<UpdateClient::PetStashEffectBr*>(istr->GetBuffer());

			int charIndex = pRecv->charIndex;
			int EffectNo = pRecv->effectNo;

			if (charIndex == _pNetwork->MyCharacterInfo.index)
				return;

			ObjectBase* pObject = ACTORMGR()->GetObject(eOBJ_CHARACTER, charIndex);

			if (pObject != NULL)
			{
				CCharacterTarget* pTarget = static_cast< CCharacterTarget* >(pObject);

				pTarget->cha_itemEffect.AddPetStashEffect( EffectNo, &(pTarget->m_pEntity->en_pmiModelInstance->m_tmSkaTagManager) );
			}
		}
		break;

	case MSG_PET_STASH_ERROR:
		{
			ResponseClient::PetStashError* pRecv = reinterpret_cast<ResponseClient::PetStashError*>(istr->GetBuffer());
			int errorCode = pRecv->errorCode;
						
			_PetErrorSystemMessage(errorCode);
		}
		break;

	case MSG_PET_STASH_PROXY_UPDATE:
		{
			UpdateClient::PetStashProxyReg* pRecv = reinterpret_cast<UpdateClient::PetStashProxyReg*>(istr->GetBuffer());
			m_nProxyPetIndex = pRecv->virtualIndex;
		}
		break;

	case MSG_PET_STASH_PROXY_CANCEL_UPDATE:
		{
			UpdateClient::PetStashProxyCancel* pRecv = reinterpret_cast<UpdateClient::PetStashProxyCancel*>(istr->GetBuffer());
			m_nProxyPetIndex = pRecv->virtualIndex;
		}
		break;
	}

	if (pStash->IsVisible() != FALSE)
		pStash->UpdateUI();
}