Beispiel #1
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)
        }
    }
}
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;
                }
		    }
	    }
    }
}
Beispiel #3
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);
}
Beispiel #4
0
void CRecastContainer::DeleteByIndex(RECASTTYPE type, uint8 index)
{
	RecastList_t* PRecastList = GetRecastList(type);
    if (type == RECAST_ABILITY)
        Sql_Query(SqlHandle, "DELETE FROM char_recast WHERE charid = %u AND id = %u;", m_PChar->id, PRecastList->at(index)->ID);
	delete PRecastList->at(index);
	PRecastList->erase(PRecastList->begin() + index);
}
bool CRecastContainer::Has(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    return std::find_if(PRecastList->begin(), PRecastList->end(), [&id](auto& recast)
    {
        return recast.ID == id;
    }) != PRecastList->end();
}
void CRecastContainer::Del(RECASTTYPE type)
{
    RecastList_t* PRecastList = GetRecastList(type);

    for (uint16 i = 0; i < PRecastList->size(); ++i)
	{
        delete PRecastList->at(i);
	}
    PRecastList->clear();
}
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);
	    }
    }
}
Beispiel #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);
}
void CRecastContainer::DeleteByIndex(RECASTTYPE type, uint8 index)
{
    RecastList_t* PRecastList = GetRecastList(type);
    if (type == RECAST_ABILITY)
    {
        PRecastList->at(index).RecastTime = 0;
    }
    else
    {
        PRecastList->erase(PRecastList->begin() + index);
    }
}
Recast_t* CRecastContainer::GetRecast(RECASTTYPE type, uint16 id)
{
    RecastList_t* list = GetRecastList(type);
    for (std::vector<Recast_t*>::iterator it = list->begin() ; it != list->end(); ++it)
    {
        Recast_t* recast = *it;
        if( recast->ID == id)
        {
            return recast;
        }
    }
    return NULL;
}
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;
}
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;
}
void CRecastContainer::Del(RECASTTYPE type)
{
    RecastList_t* PRecastList = GetRecastList(type);
    if (type == RECAST_ABILITY)
    {
        for (auto&& recast : *PRecastList)
        {
            recast.RecastTime = 0;
        }
    }
    else
    {
        PRecastList->clear();
    }
}
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;
}
void CRecastContainer::Del(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    if (type == RECAST_ABILITY)
    {
        if (auto recast = GetRecast(RECAST_ABILITY, id))
        {
            recast->RecastTime = 0;
        }
    }
    else
    {
        PRecastList->erase(std::remove_if(PRecastList->begin(), PRecastList->end(), [&id](auto& recast)
        {
            return recast.ID == id;
        }), PRecastList->end());
    }
}
void CRecastContainer::ResetAbilities()
{
    RecastList_t* PRecastList = GetRecastList(RECAST_ABILITY);

    uint32 timestamp = 0;
    uint32 recastTime = 0;

    Recast_t* twoHour = GetRecast(RECAST_ABILITY, 0);
    if (twoHour != NULL)
    {
        timestamp = twoHour->TimeStamp;
        recastTime = twoHour->RecastTime;
    }
    PRecastList->clear();
    if (twoHour != NULL)
    {
        Recast_t* newTwoHour = new Recast_t;
        newTwoHour->ID = 0;
        newTwoHour->TimeStamp = timestamp;
        newTwoHour->RecastTime = recastTime;
        PRecastList->push_back(newTwoHour);
    }
}
Beispiel #17
0
void CRecastContainer::ResetAbilities()
{
    RecastList_t* PRecastList = GetRecastList(RECAST_ABILITY);

    uint32 timestamp = 0;
    uint32 recastTime = 0;

    Recast_t* twoHour = GetRecast(RECAST_ABILITY, 0);
    if (twoHour != nullptr)
    {
        timestamp = twoHour->TimeStamp;
        recastTime = twoHour->RecastTime;
    }
    PRecastList->clear();
    if (twoHour != nullptr)
    {
        Recast_t* newTwoHour = new Recast_t;
        newTwoHour->ID = 0;
        newTwoHour->TimeStamp = timestamp;
        newTwoHour->RecastTime = recastTime;
        PRecastList->push_back(newTwoHour);
    }
    Sql_Query(SqlHandle, "DELETE FROM char_recast WHERE charid = %u AND id != 0;", m_PChar->id);
}
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;
                }
            }
        }
    }
}
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;
        }
	}
}
Beispiel #20
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;
        }
	}
}
void CRecastContainer::DeleteByIndex(RECASTTYPE type, uint8 index)
{
	RecastList_t* PRecastList = GetRecastList(type);
	delete PRecastList->at(index);
	PRecastList->erase(PRecastList->begin() + index);
}