Exemplo n.º 1
0
/**
* @brief        Gets NPC information for use in various NPC packets.
*
* @param        pkt        The packet the information will be stored in.
*/
void CNpc::GetNpcInfo(Packet & pkt)
{
        pkt << GetProtoID()
                << uint8(isMonster() ? 1 : 2) // Monster = 1, NPC = 2 (need to use a better flag)
                << m_sPid
                << GetType()
                << m_iSellingGroup
                << m_sSize
                << m_iWeapon_1 << m_iWeapon_2
                // Monsters require 0 regardless, otherwise they'll act as NPCs.
                << uint8(isMonster() ? 0 : GetNation())
                << GetLevel()
                << GetSPosX() << GetSPosZ() << GetSPosY()
                << uint32(isGateOpen())
                << m_byObjectType
                << uint16(0) << uint16(0) // unknown
                << int16(m_byDirection);
}
Exemplo n.º 2
0
/**
* @brief        Executes the death action.
*
* @param        pKiller        The killer.
*/
void CNpc::OnDeath(Unit *pKiller)
{
        if (m_NpcState == NPC_DEAD)
                return;

        ASSERT(GetMap() != nullptr);
        ASSERT(GetRegion() != nullptr);

        m_NpcState = NPC_DEAD;

        if (m_byObjectType == SPECIAL_OBJECT)
        {
                _OBJECT_EVENT *pEvent = GetMap()->GetObjectEvent(GetProtoID());
                if (pEvent != nullptr)
                        pEvent->byLife = 0;
        }

        Unit::OnDeath(pKiller);
        OnDeathProcess(pKiller);

        GetRegion()->Remove(TO_NPC(this));
        SetRegion();
}
Exemplo n.º 3
0
/**
* @brief	Executes the death action.
*
* @param	pKiller	The killer.
*/
void CNpc::OnDeath(Unit *pKiller)
{
	if (m_NpcState == NPC_DEAD)
		return;

	ASSERT(GetMap() != nullptr);
	ASSERT(GetRegion() != nullptr);

	m_NpcState = NPC_DEAD;

	if (m_byObjectType == SPECIAL_OBJECT)
	{
		_OBJECT_EVENT *pEvent = GetMap()->GetObjectEvent(GetProtoID());
		if (pEvent != nullptr)
			pEvent->byLife = 0;
	}

	Unit::OnDeath(pKiller);

	CNpc * pNpc = TO_NPC(this);
	CUser * pUser = TO_USER(pKiller);

	if (pNpc != nullptr && pUser != nullptr)
	{
		if (pNpc->isMonster() && pUser->isPlayer())
		{
			if (pNpc->m_sSid == 700 || pNpc->m_sSid == 750)
			{
				if (pUser->CheckExistEvent(STARTER_SEED_QUEST, 0) || pUser->CheckExistEvent(STARTER_SEED_QUEST, 1))
					pUser->SaveEvent(STARTER_SEED_QUEST, 2);
			}
		}
	}

	GetRegion()->Remove(TO_NPC(this));
	SetRegion();
}