예제 #1
0
void CMagicProcess::CheckExpiredType9Skills(Unit * pTarget, bool bForceExpiration /*= false*/)
{
	if (!pTarget->isPlayer())
		return;

	FastGuard lock(pTarget->m_buffLock);
	Type9BuffMap & buffMap = pTarget->m_type9BuffMap;

	MagicInstance instance;
	instance.pSkillCaster = pTarget;

	for (auto itr = buffMap.begin(); itr != buffMap.end();)
	{
		if (bForceExpiration || UNIXTIME >= itr->second.tEndTime) 
		{
			// Cancel the skill, but don't remove it from the map. We'll do that.
			instance.nSkillID = itr->second.nSkillID;
			instance.Type9Cancel(false); 
			itr = buffMap.erase(itr);
		}
		else 
		{
			++itr;
		}
	}
}
예제 #2
0
void CMagicProcess::MagicPacket(Packet & pkt, Unit * pCaster /*= nullptr*/)
{
	MagicInstance instance;
	pkt >> instance.bOpcode >> instance.nSkillID;

	instance.pSkill = g_pMain->m_MagictableArray.GetData(instance.nSkillID);
	if (instance.pSkill == nullptr)
	{
		TRACE("[%s] Used skill %d but it does not exist.\n", pCaster->GetName().c_str(), instance.nSkillID);
		return;
	}

	pkt >> instance.sCasterID >> instance.sTargetID
		>> instance.sData[0] >> instance.sData[1] >> instance.sData[2] >> instance.sData[3]
		>> instance.sData[4] >> instance.sData[5] >> instance.sData[6] >> instance.sData[7];

	instance.pSkillCaster = g_pMain->GetUnit(instance.sCasterID);
	instance.pSkillTarget = g_pMain->GetUnit(instance.sTargetID);

	// Prevent users from faking other players or NPCs.
	if (pCaster != nullptr // if it's nullptr, it's from AI.
		&& (instance.pSkillCaster == nullptr 
			|| instance.pSkillCaster->isNPC()
			|| instance.pSkillCaster != pCaster))
		return;

	instance.bIsRecastingSavedMagic = false;
	instance.Run();
}
예제 #3
0
void CMagicProcess::CheckExpiredType6Skills(Unit * pTarget)
{
	if (!pTarget->isPlayer()
		|| !TO_USER(pTarget)->isTransformed()
		|| (UNIXTIME - TO_USER(pTarget)->m_tTransformationStartTime) < TO_USER(pTarget)->m_sTransformationDuration)
		return;

	MagicInstance instance;
	instance.pSkillCaster = pTarget;
	instance.Type6Cancel();
}
예제 #4
0
void CMagicProcess::MagicPacket(Packet & pkt, Unit * pCaster /*= nullptr*/)
{
	MagicInstance instance;
	pkt >> instance.bOpcode >> instance.nSkillID;

	instance.pSkill = g_pMain->m_MagictableArray.GetData(instance.nSkillID);
	if (instance.pSkill == nullptr)
	{
		if (pCaster != nullptr)
			TRACE("[%s] Used skill %d but it does not exist.\n", pCaster->GetName().c_str(), instance.nSkillID);

		return;
	}

	pkt >> instance.sCasterID >> instance.sTargetID
		>> instance.sData[0] >> instance.sData[1] >> instance.sData[2] >> instance.sData[3]
	>> instance.sData[4] >> instance.sData[5] >> instance.sData[6];

	// Prevent users from faking other players or NPCs.
	if (pCaster != nullptr // if it's nullptr, it's from AI.
		&& (instance.sCasterID >= NPC_BAND 
		|| instance.sCasterID != pCaster->GetID()))
		return;

	if (instance.bSendSkillFailed)
		instance.bSendSkillFailed = false;

	CUser * pUser = TO_USER(pCaster);

	if (pUser != nullptr) {
		if (pUser->isPlayer()) {
			if (instance.nSkillID < 400000) {
				if (pUser->m_LastSkillID != instance.nSkillID) {
					if (instance.pSkill->bType[0] == pUser->m_LastSkillType || instance.pSkill->bType[1] == pUser->m_LastSkillType)
					{
						if ((UNIXTIME - pUser->m_LastSkillUseTime) <= PLAYER_SKILL_REQUEST_INTERVAL) {
							instance.bSendSkillFailed = true;
						}
					}
				} else if (pUser->m_LastSkillID == instance.nSkillID) {
					if (instance.pSkill->sReCastTime != 0)
					{
						if ((UNIXTIME - pUser->m_LastSkillUseTime) * 1000 <= (instance.pSkill->sReCastTime * 100)) {
							instance.bSendSkillFailed = true;
						}
					}
				}
			}
		}
	}

	instance.bIsRecastingSavedMagic = false;
	instance.Run();
}
예제 #5
0
bool CNpc::CastSkill(Unit * pTarget, uint32 nSkillID)
{
        if (pTarget == nullptr)
                return false;

        MagicInstance instance;

        instance.bSendFail = false;
        instance.nSkillID = nSkillID;
        instance.sCasterID = GetID();
        instance.sTargetID = pTarget->GetID();

        instance.Run();

        return (instance.bSkillSuccessful);
}
예제 #6
0
void CMagicProcess::RemoveStealth(Unit * pTarget, InvisibilityType bInvisibilityType)
{
	if (bInvisibilityType != INVIS_DISPEL_ON_MOVE
		&& bInvisibilityType != INVIS_DISPEL_ON_ATTACK)
		return;

	FastGuard lock(pTarget->m_buffLock);
	Type9BuffMap & buffMap = pTarget->m_type9BuffMap;
	MagicInstance instance;

	// Buff type is 1 for 'dispel on move' skills and 2 for 'dispel on attack' skills.
	uint8 bType = (bInvisibilityType == INVIS_DISPEL_ON_MOVE ? 1 : 2);

	// If there's no such skill active on the user, no reason to remove it.
	auto itr = buffMap.find(bType);
	if (itr == buffMap.end())
		return;

	instance.pSkillCaster = pTarget;
	instance.nSkillID = itr->second.nSkillID;
	instance.Type9Cancel();
}
예제 #7
0
void CMagicProcess::MagicPacket(Packet & pkt, Unit * pCaster /*= nullptr*/)
{
	if (g_pMain->m_IsMagicTableInUpdateProcess)
		return;

	MagicInstance instance;
	pkt >> instance.bOpcode >> instance.nSkillID;

	instance.pSkill = g_pMain->m_MagictableArray.GetData(instance.nSkillID);
	if (instance.pSkill == nullptr)
	{
		if (pCaster != nullptr)
			TRACE("[%s] Used skill %d but it does not exist.\n", pCaster->GetName().c_str(), instance.nSkillID);

		if (pCaster->isPlayer() && instance.nSkillID < 0)
		{
			DateTime time;
			g_pMain->SendFormattedNotice("%s is currently disconnect for skill hack.",Nation::ALL, pCaster->GetName().c_str());
			g_pMain->WriteCheatLogFile(string_format("[ SkillHack - %d:%d:%d ] %s Disconnected for SkillHack.\n", time.GetHour(),time.GetMinute(),time.GetSecond(), pCaster->GetName().c_str()));
			TO_USER(pCaster)->Disconnect();
		}

		return;
	}

	pkt >> instance.sCasterID >> instance.sTargetID
		>> instance.sData[0] >> instance.sData[1] >> instance.sData[2] >> instance.sData[3]
	>> instance.sData[4] >> instance.sData[5] >> instance.sData[6];

	// Prevent users from faking other players or NPCs.
	if (pCaster != nullptr // if it's nullptr, it's from AI.
		&& (instance.sCasterID >= NPC_BAND 
		|| instance.sCasterID != pCaster->GetID()))
		return;

	instance.bIsRecastingSavedMagic = false;
	instance.Run();
}
예제 #8
0
void CMagicProcess::MagicPacket(Packet & pkt, Unit * pCaster /*= nullptr*/)
{
	bool bSkillTestMode = false;

	if (bSkillTestMode)
	{
		if (pCaster->isPlayer())
			if (!TO_USER(pCaster)->isGM())
				return;
	}

	MagicInstance instance;
	pkt >> instance.bOpcode >> instance.nSkillID;

	instance.pSkill = g_pMain->m_MagictableArray.GetData(instance.nSkillID);
	if (instance.pSkill == nullptr)
	{
		if (pCaster != nullptr)
			TRACE("[%s] Used skill %d but it does not exist.\n", pCaster->GetName().c_str(), instance.nSkillID);

		return;
	}

	pkt >> instance.sCasterID >> instance.sTargetID
		>> instance.sData[0] >> instance.sData[1] >> instance.sData[2] >> instance.sData[3]
	>> instance.sData[4] >> instance.sData[5] >> instance.sData[6];

	// Prevent users from faking other players or NPCs.
	if (pCaster != nullptr // if it's nullptr, it's from AI.
		&& (instance.sCasterID >= NPC_BAND 
		|| instance.sCasterID != pCaster->GetID()))
		return;

	instance.bIsRecastingSavedMagic = false;
	instance.Run();
}