Exemplo n.º 1
0
void CParty::DisbandParty()
{
	SetSyncTarget(NULL);
	SetQuaterMaster(NULL);

	m_PLeader = NULL;
	m_PAlliance	= NULL;

    if (m_PartyType == PARTY_PCS)
    {
        PushPacket(NULL, 0, new CPartyDefinePacket(NULL));

	    for (uint8 i = 0; i < members.size(); ++i)
	    {
		    CCharEntity* PChar = (CCharEntity*)members.at(i);

		    PChar->PParty = NULL;
		    PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, PChar->getZone()));

		    // TODO: TreasurePool должен оставаться у последнего персонажа, но сейчас это не критично

            if (PChar->PTreasurePool != NULL &&
                PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
		    {
			    PChar->PTreasurePool->DelMember(PChar);
			    PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
			    PChar->PTreasurePool->AddMember(PChar);
                PChar->PTreasurePool->UpdatePool(PChar);
		    }
	    }
        Sql_Query(SqlHandle,"UPDATE accounts_sessions SET partyid = %u WHERE partyid = %u", 0, m_PartyID);
    }
	delete this;
}
Exemplo n.º 2
0
void CParty::AssignPartyRole(int8* MemberName, uint8 role)
{
    DSP_DEBUG_BREAK_IF (m_PartyType != PARTY_PCS);

	switch(role)
	{
		case 0: SetLeader(MemberName);		    break;
        case 4: SetQuarterMaster(MemberName);    break;
		case 5: SetQuarterMaster(NULL);	        break;
        case 6: SetSyncTarget(MemberName, 238);	break;
        case 7: SetSyncTarget(NULL, 553);       break;
	}
	uint8 data[4];
	WBUFL(data, 0) = m_PartyID;
    message::send(MSG_PT_RELOAD, data, sizeof data, NULL);
	return;
}
Exemplo n.º 3
0
void CParty::AssignPartyRole(int8* MemberName, uint8 role)
{
    DSP_DEBUG_BREAK_IF(m_PartyType != PARTY_PCS);

    switch (role)
    {
        case 0: SetLeader((const char*)MemberName);		    break;
        case 4: SetQuarterMaster((const char*)MemberName);   break;
        case 5: SetQuarterMaster(nullptr);	        break;
        case 6: SetSyncTarget(MemberName, 238);	break;
        case 7: SetSyncTarget(nullptr, 553);       break;
    }
    uint8 data[4] {};
    ref<uint32>(data, 0) = m_PartyID;
    message::send(MSG_PT_RELOAD, data, sizeof data, nullptr);
    return;
}
Exemplo n.º 4
0
void CParty::RemoveMember(CBattleEntity* PEntity)
{
	DSP_DEBUG_BREAK_IF(PEntity == NULL);
	DSP_DEBUG_BREAK_IF(PEntity->PParty != this);

	if (m_PLeader == PEntity)
	{
		RemovePartyLeader(PEntity);
	}
	else
	{
		for (uint32 i = 0; i < members.size(); ++i)
		{
			if (PEntity == members.at(i))
			{
				members.erase(members.begin()+i);

                if (m_PartyType == PARTY_PCS)
                {
                    CCharEntity* PChar = (CCharEntity*)PEntity;

				    if (m_PQuaterMaster == PChar)
				    {
					    SetQuaterMaster(NULL);
				    }
				    if (m_PSyncTarget == PChar)
				    {
					    SetSyncTarget(NULL);
				    }

				    PChar->pushPacket(new CPartyDefinePacket(NULL));
				    PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, PChar->getZone()));
				    PChar->pushPacket(new CCharUpdatePacket(PChar));
				    PChar->pushPacket(new CCharSyncPacket(PChar));
				    PChar->PParty = NULL;

				    ReloadParty();

				    if (PChar->PTreasurePool != NULL &&
					    PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
				    {
					    PChar->PTreasurePool->DelMember(PChar);
					    PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
					    PChar->PTreasurePool->AddMember(PChar);
                        PChar->PTreasurePool->UpdatePool(PChar);
				    }
				    Sql_Query(SqlHandle,"UPDATE accounts_sessions SET partyid = 0 WHERE charid = %u", PChar->id);
                }
				break;
			}
		}
	}
}
Exemplo n.º 5
0
void CParty::AssignPartyRole(int8* MemberName, uint8 role)
{
    DSP_DEBUG_BREAK_IF (m_PartyType != PARTY_PCS);

	for (uint32 i = 0; i < members.size(); ++i)
	{
		CCharEntity* PChar = (CCharEntity*)members.at(i);

		if (strcmp(MemberName, PChar->GetName()) == 0)
		{
			switch(role)
			{
				case 0: SetLeader(PChar);		break;
				case 4: SetQuaterMaster(PChar); break;
				case 5: SetQuaterMaster(NULL);	break;
			    case 6: SetSyncTarget(PChar, 238);	break;
                case 7: SetSyncTarget(NULL, 553);    break;
			}
            ReloadParty();
		    return;
        }
    }
    ShowError(CL_RED"The character with name <%s> isn't found in party\n" CL_RESET, MemberName);
}
Exemplo n.º 6
0
void CParty::RefreshSync()
{
    CCharEntity* sync = (CCharEntity*)m_PSyncTarget;
    uint8 syncLevel = sync->jobs.job[sync->GetMJob()];
    if (syncLevel < 10)
    {
        SetSyncTarget(NULL, 554);
    }
    for (uint32 i = 0; i < members.size(); ++i)
	{
		if(members.at(i)->objtype != TYPE_PC) continue;

		CCharEntity* member = (CCharEntity*)members.at(i);

        uint8 NewMLevel = 0;

		if (syncLevel < member->jobs.job[member->GetMJob()])
		{
			NewMLevel = syncLevel;
		}else{
			NewMLevel = member->jobs.job[member->GetMJob()];
		}

		if (member->GetMLevel() != NewMLevel)
		{
            charutils::RemoveAllEquipMods(member);
			member->SetMLevel(NewMLevel);
			member->SetSLevel(member->jobs.job[member->GetSJob()]);
            charutils::ApplyAllEquipMods(member);

            blueutils::ValidateBlueSpells(member);
			charutils::BuildingCharSkillsTable(member);
			charutils::CalculateStats(member);
			charutils::BuildingCharTraitsTable(member);
			charutils::BuildingCharAbilityTable(member);
			charutils::CheckValidEquipment(member); // Handles rebuilding weapon skills as well.
		}
        member->pushPacket(new CMessageBasicPacket(member, member, 0, syncLevel, 540));
	}
    m_PSyncTarget = sync;
}
Exemplo n.º 7
0
void CParty::DelMember(CBattleEntity* PEntity)
{
	DSP_DEBUG_BREAK_IF(PEntity == NULL);
	DSP_DEBUG_BREAK_IF(PEntity->PParty != this);

	if (m_PLeader == PEntity)
	{
		RemovePartyLeader(PEntity);
	}
	else
	{
		for (uint32 i = 0; i < members.size(); ++i)
		{
			if (PEntity == members.at(i))
			{
				members.erase(members.begin() + i);

				if (m_PartyType == PARTY_PCS)
				{
					CCharEntity* PChar = (CCharEntity*)PEntity;

					if (m_PQuaterMaster == PChar)
					{
						SetQuarterMaster(NULL);
					}
					if (m_PSyncTarget == PChar)
					{
						SetSyncTarget(NULL, 553);
						CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
						if (sync && sync->GetDuration() == 0)
						{
							PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
							sync->SetStartTime(gettick());
							sync->SetDuration(30000);
						}
						DisableSync();
					}
					if (m_PSyncTarget != NULL && m_PSyncTarget != PChar)
					{
						if (PChar->status != STATUS_DISAPPEAR &&
							PChar->getZone() == m_PSyncTarget->getZone())
						{
							CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
							if (sync && sync->GetDuration() == 0)
							{
								PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
								sync->SetStartTime(gettick());
								sync->SetDuration(30000);
							}
						}
					}
					PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size());

					PChar->pushPacket(new CPartyDefinePacket(NULL));
					PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, PChar->getZone()));
					PChar->pushPacket(new CCharUpdatePacket(PChar));
					PChar->PParty = NULL;

					if (PChar->PTreasurePool != NULL &&
						PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
					{
						PChar->PTreasurePool->DelMember(PChar);
						PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
						PChar->PTreasurePool->AddMember(PChar);
						PChar->PTreasurePool->UpdatePool(PChar);
					}
				}
				break;
			}
		}
	}
}
Exemplo n.º 8
0
void CParty::RemoveMember(CBattleEntity* PEntity)
{
    DSP_DEBUG_BREAK_IF(PEntity == nullptr);
    DSP_DEBUG_BREAK_IF(PEntity->PParty != this);

    if (m_PLeader == PEntity)
    {
        RemovePartyLeader(PEntity);
    }
    else
    {
        for (uint32 i = 0; i < members.size(); ++i)
        {
            if (PEntity == members.at(i))
            {
                members.erase(members.begin() + i);

                if (m_PartyType == PARTY_PCS)
                {
                    CCharEntity* PChar = (CCharEntity*)PEntity;

                    if (m_PQuaterMaster == PChar)
                    {
                        SetQuarterMaster(nullptr);
                    }
                    if (m_PSyncTarget == PChar)
                    {
                        SetSyncTarget(nullptr, 553);
                        CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
                        if (sync && sync->GetDuration() == 0)
                        {
                            PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
                            sync->SetStartTime(server_clock::now());
                            sync->SetDuration(30000);
                        }
                        DisableSync();
                    }
                    if (m_PSyncTarget != nullptr && m_PSyncTarget != PChar)
                    {
                        if (PChar->status != STATUS_DISAPPEAR)
                        {
                            CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
                            if (sync && sync->GetDuration() == 0)
                            {
                                PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
                                sync->SetStartTime(server_clock::now());
                                sync->SetDuration(30000);
                            }
                        }
                    }
                    PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size());

                    PChar->pushPacket(new CPartyDefinePacket(nullptr));
                    PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, 0, PChar->getZone()));
                    PChar->pushPacket(new CCharUpdatePacket(PChar));
                    PChar->PParty = nullptr;

                    Sql_Query(SqlHandle, "DELETE FROM accounts_parties WHERE charid = %u;", PChar->id);

                    uint8 data[4] {};
                    ref<uint32>(data, 0) = m_PartyID;
                    message::send(MSG_PT_RELOAD, data, sizeof data, nullptr);

                    if (PChar->PTreasurePool != nullptr &&
                        PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
                    {
                        PChar->PTreasurePool->DelMember(PChar);
                        PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
                        PChar->PTreasurePool->AddMember(PChar);
                        PChar->PTreasurePool->UpdatePool(PChar);
                    }
                }
                break;
            }
        }
    }
}