本文整理汇总了C++中MagicInstance类的典型用法代码示例。如果您正苦于以下问题:C++ MagicInstance类的具体用法?C++ MagicInstance怎么用?C++ MagicInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MagicInstance类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
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: MagicPacket
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: TO_USER
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: MagicPacket
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: CastSkill
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: MagicPacket
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();
}
示例7: MagicPacket
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();
}