Exemplo n.º 1
0
bool CRecastContainer::HasRecast(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        if (PRecastList->at(i)->ID == id && PRecastList->at(i)->RecastTime > 0)
        {
            if (PRecastList->at(i)->chargeTime == 0)
            {
                return true;
            }
            else
            {
                int charges = PRecastList->at(i)->maxCharges - ((PRecastList->at(i)->RecastTime - (gettick() - PRecastList->at(i)->TimeStamp)) / (PRecastList->at(i)->chargeTime * 1000)) - 1;

                //TODO: multiple charges (BST Ready)
                if (charges < 1)
                {
                    return true;
                }
            }
        }
	}
    return false;
}
Exemplo n.º 2
0
void CRecastContainer::Check(uint32 tick)
{
	DSP_DEBUG_BREAK_IF(tick == 0);

    for (uint8 type = 0; type < MAX_RECASTTPE_SIZE; ++type)
    {
        RecastList_t* PRecastList = GetRecastList((RECASTTYPE)type);

        for (uint16 i = 0; i < PRecastList->size(); ++i)
	    {
		    Recast_t* recast = PRecastList->at(i);

		    if (tick >= (recast->TimeStamp + recast->RecastTime))
		    {
                if (type == RECAST_ITEM)
                {
                    CItem* PItem = m_PChar->getStorage(LOC_INVENTORY)->GetItem(recast->ID);

                    m_PChar->pushPacket(new CInventoryItemPacket(PItem, LOC_INVENTORY, recast->ID));
	                m_PChar->pushPacket(new CInventoryFinishPacket());
                }
                if (type == RECAST_ITEM || type == RECAST_MAGIC || type == RECAST_LOOT)
                {
                    PRecastList->erase(PRecastList->begin() + i--);
                    delete recast;
                }
                else
                {
                    recast->RecastTime = 0;
                }
		    }
	    }
    }
}
Exemplo n.º 3
0
CCharRecastPacket::CCharRecastPacket(CCharEntity* PChar)
{
    this->type = 0x19;
    this->size = 0x7F;

    uint8 count = 0;

    RecastList_t* RecastList = PChar->PRecastContainer->GetRecastList(RECAST_ABILITY);

    for (uint16 i = 0; i < RecastList->size(); ++i)
    {
        Recast_t* recast = RecastList->at(i);

        uint32 recasttime = (recast->RecastTime == 0 ? 0 : ((recast->RecastTime - (time(nullptr) - recast->TimeStamp))));

        if (recast->ID != 0)
        {
            WBUFL(data, (0x0C + count * 8) ) = recasttime;
            WBUFB(data, (0x0F + count * 8) ) = recast->ID;
            count++;
        }
        else
        {
            WBUFL(data, (0x04) ) = recasttime;  // 2h ability (recast id is 0)
        }
    }
}
Exemplo n.º 4
0
bool CRecastContainer::HasRecast(RECASTTYPE type, uint16 id, uint32 recast)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
    {
        if (PRecastList->at(i).ID == id && PRecastList->at(i).RecastTime > 0)
        {
            if (PRecastList->at(i).chargeTime == 0)
            {
                return true;
            }
            else
            {
                //a request to use more charges than the maximum only applies to abilities who share normal recasts with charges (ie. sic)
                if ( recast > PRecastList->at(i).maxCharges )
                {
                    return true;
                }
                auto charges = PRecastList->at(i).maxCharges - ((PRecastList->at(i).RecastTime - (uint32)(time(nullptr) - PRecastList->at(i).TimeStamp)) / (PRecastList->at(i).chargeTime)) - 1;

                if (charges < recast)
                {
                    return true;
                }
            }
        }
    }
    return false;
}
Exemplo n.º 5
0
CCharSkillsPacket::CCharSkillsPacket(CCharEntity* PChar) 
{
	this->type = 0x62;
	this->size = 0x80;

	uint8 count = 0; 

    RecastList_t* RecastList = PChar->PRecastContainer->GetRecastList(RECAST_ABILITY);

    for (uint16 i = 0; i < RecastList->size(); ++i) 
	{
        Recast_t* recast = RecastList->at(i);

		uint32 time = (recast->RecastTime == 0 ? 0 : ((recast->RecastTime - (gettick() - recast->TimeStamp)) / 1000));

		if(recast->ID != 0) 
		{
            WBUFL(data,(0x08 + count*4)-4) = time;
            WBUFB(data,(0x0B + count*4)-4) = recast->ID;
			count++;
		} 
		else
		{
            WBUFL(data,(0x04)-4) = time;  // 2h ability (recast id is 0)
		}
    }
	memcpy(data+(0x80)-4, &PChar->WorkingSkills, 128);
}
Exemplo n.º 6
0
void CRecastContainer::Del(RECASTTYPE type)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        delete PRecastList->at(i);
	}
    PRecastList->clear();
}
Exemplo n.º 7
0
CRecastContainer::~CRecastContainer()
{
    for (uint8 type = 0; type < MAX_RECASTTPE_SIZE; ++type)
    {
        RecastList_t* PRecastList = GetRecastList((RECASTTYPE)type);

        for (uint16 i = 0; i < PRecastList->size(); ++i)
	    {
		    delete PRecastList->at(i);
	    }
    }
}
Exemplo n.º 8
0
void CRecastContainer::Del(RECASTTYPE type)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        delete PRecastList->at(i);
	}
    PRecastList->clear();
    if (type == RECAST_ABILITY)
        Sql_Query(SqlHandle, "DELETE FROM char_recast WHERE charid = %u;", m_PChar->id);
}
Exemplo n.º 9
0
bool CRecastContainer::Has(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        if (PRecastList->at(i)->ID == id)
        {
            return true;
        }
	}
    return false;
}
Exemplo n.º 10
0
void CRecastContainer::Del(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        if (PRecastList->at(i)->ID == id)
        {
            delete PRecastList->at(i);
            PRecastList->erase(PRecastList->begin() + i);
            return;
        }
	}
}
Exemplo n.º 11
0
void CRecastContainer::Del(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        if (PRecastList->at(i)->ID == id)
        {
            if (type == RECAST_ABILITY)
                Sql_Query(SqlHandle, "DELETE FROM char_recast WHERE charid = %u AND id = %u;", m_PChar->id, PRecastList->at(i)->ID);
            delete PRecastList->at(i);
            PRecastList->erase(PRecastList->begin() + i);
            return;
        }
	}
}
Exemplo n.º 12
0
void CRecastContainer::Check()
{
    for (auto type : {RECAST_MAGIC, RECAST_ABILITY})
    {
        RecastList_t* PRecastList = GetRecastList(type);

        for (uint16 i = 0; i < PRecastList->size(); ++i)
        {
            Recast_t* recast = &PRecastList->at(i);

            if (time(nullptr) >= (recast->TimeStamp + recast->RecastTime))
            {
                if (type == RECAST_MAGIC)
                {
                    PRecastList->erase(PRecastList->begin() + i--);
                }
                else
                {
                    recast->RecastTime = 0;
                }
            }
        }
    }
}