本文整理汇总了C++中CArea::FindCharInCell方法的典型用法代码示例。如果您正苦于以下问题:C++ CArea::FindCharInCell方法的具体用法?C++ CArea::FindCharInCell怎么用?C++ CArea::FindCharInCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArea
的用法示例。
在下文中一共展示了CArea::FindCharInCell方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_Attack
void do_Attack(CPC* pc, CNetMsg::SP& msg)
{
CDratanCastle * pCastle = CDratanCastle::CreateInstance();
pCastle->CheckRespond(pc);
RequestClient::doAttack* packet = reinterpret_cast<RequestClient::doAttack*>(msg->m_buf);
// 동시 공격은 최대 5
if (packet->multicount > 5)
{
LOG_ERROR("HACKING : invalid multi count[%d]. charIndex[%d]", packet->multicount, pc->m_index);
pc->m_desc->Close("invalid multi count");
return;
}
// multi target의 중복 검사
if (packet->multicount > 1)
{
std::set<int> tset;
for (int i = 0; i < packet->multicount; ++i)
{
if (tset.insert(packet->list[i].index).second == false)
{
LOG_ERROR("HACKING : duplicate multi target[%d]. charIndex[%d]", packet->list[i].index, pc->m_index);
pc->m_desc->Close("duplicate multi target");
return;
}
}
}
// 대상 검색 : 인접 셀에서만
CArea* area = pc->m_pArea;
if (area == NULL)
return;
CCharacter* ch = area->FindCharInCell(pc, packet->aIndex, (MSG_CHAR_TYPE)packet->aCharType);
if (ch == NULL)
return;
CCharacter* tch = area->FindCharInCell(ch, packet->tIndex, (MSG_CHAR_TYPE)packet->tCharType);
if (tch == NULL)
return;
// 공격자가 PC이면 자신의 캐릭만 조정
if (IS_PC(ch) && ch != pc)
return ;
switch (ch->m_type)
{
case MSG_CHAR_PC:
{
if( IS_NPC(tch))
{
CPC * pPC = TO_PC(ch);
CNPC * pNPC = TO_NPC(tch);
if( pPC->GetSummonNpc(SUMMON_NPC_TYPE_MERCENARY) == pNPC )
return;
}
//pvp보호 아이템 체크
if (checkPvPProtect(pc, tch) == false)
return;
// 공격 거리 검사
if (GetDistance(ch, tch) > ch->m_attackRange * 2)
return ;
// 공속 검사
if ( ch->ChekAttackType() && ch->CheckHackAttack(pc))
return ;
// 펫 타고 있으면 불가능
if (pc->GetPet() && pc->GetPet()->IsMount())
return ;
// 공성 아이템 착용시 해당 스킬 발동
int mixSkillIndex[] = { pc->m_opSturnIndex, pc->m_opBloodIndex, pc->m_opPoisonIndex, pc->m_opSlowIndex, pc->m_opMoveIndex };
int mixSkillLevel[] = { pc->m_opSturnLevel, pc->m_opBloodLevel, pc->m_opPoisonLevel, pc->m_opSlowLevel, pc->m_opMoveLevel };
CSkill* skillMixItem = NULL;
int i;
int bStop = 0;
for (i = 0; i < 5; i++)
{
if (mixSkillIndex[i] > 0 && mixSkillLevel[i] > 0)
{
skillMixItem = gserver->m_skillProtoList.Create(mixSkillIndex[i], mixSkillLevel[i]);
if (skillMixItem)
{
bool bApply;
bStop = ApplySkill(ch, tch, skillMixItem, -1, bApply);
}
delete skillMixItem;
skillMixItem = NULL;
if (bStop != 0)
return ;
}
}
if (IS_PC(ch))
{
//.........这里部分代码省略.........
示例2: do_pd_Attack
// 믈리 어택
void do_pd_Attack(CPC* pc, CNetMsg::SP& msg)
{
CDratanCastle * pCastle = CDratanCastle::CreateInstance();
pCastle->CheckRespond(pc);
RequestClient::doPDAttack* packet = reinterpret_cast<RequestClient::doPDAttack*>(msg->m_buf);
if (packet->multicount > 20)
{
LOG_ERROR("HACKING : invalid multi count[%d]. charIndex[%d]", packet->multicount, pc->m_index);
pc->m_desc->Close("invalid multi count");
return;
}
// multi target의 중복 검사
if (packet->multicount > 1)
{
std::set<int> tset;
for (int i = 0; i < packet->multicount; ++i)
{
if (tset.insert(packet->list[i].index).second == false)
{
LOG_ERROR("HACKING : duplicate multi target[%d]. charIndex[%d]", packet->list[i].index, pc->m_index);
pc->m_desc->Close("duplicate multi target");
return;
}
}
}
// 대상 검색 : 인접 셀에서만
CArea* area = pc->m_pArea;
if (area == NULL)
{
LOG_ERROR("HACKING : not found area. charIndex[%d]", pc->m_index);
pc->m_desc->Close("not found area");
return;
}
CCharacter* tch = area->FindCharInCell(pc, packet->tIndex, (MSG_CHAR_TYPE)packet->tCharType);
if (tch == NULL)
return;
int preIndex = -1;
for (int i = 0; i < packet->multicount; ++i)
{
if(preIndex == packet->list[i].index)
{
// 가까운 마을로
int nearZone;
int nearZonePos;
CZone* pZone = gserver->FindNearestZone(pc->m_pZone->m_index, GET_X(pc), GET_Z(pc), &nearZone, &nearZonePos);
if (pZone == NULL)
return;
GoZone(pc, nearZone,
pZone->m_zonePos[nearZonePos][0], // ylayer
GetRandom(pZone->m_zonePos[nearZonePos][1], pZone->m_zonePos[nearZonePos][3]) / 2.0f, // x
GetRandom(pZone->m_zonePos[nearZonePos][2], pZone->m_zonePos[nearZonePos][4]) / 2.0f); // z
return;
}
preIndex = packet->list[i].index;
CCharacter* ch = area->FindCharInCell(pc, packet->list[i].index, (MSG_CHAR_TYPE) MSG_CHAR_NPC);
if(!ch) continue;
if( !IS_NPC(ch) )
{
CPC* bugPC = NULL;
if( IS_ELEMENTAL(ch) )
{
CElemental *ele = TO_ELEMENTAL(ch);
bugPC = ele->GetOwner();
}
if( IS_PET(ch) )
{
CPet* pet = TO_PET(ch);
bugPC = pet->GetOwner();
}
if( IS_PC(ch) )
{
bugPC = TO_PC(ch);
}
if( !bugPC )
return;
// 가까운 마을로
int nearZone;
int nearZonePos;
CZone* pZone = gserver->FindNearestZone(bugPC->m_pZone->m_index, GET_X(bugPC), GET_Z(bugPC), &nearZone, &nearZonePos);
if (pZone == NULL)
return;
GoZone(bugPC, nearZone,
pZone->m_zonePos[nearZonePos][0], // ylayer
//.........这里部分代码省略.........