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(); }
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(); }
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); }
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(); }
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(); }