本文整理汇总了C++中CNpc::GetMap方法的典型用法代码示例。如果您正苦于以下问题:C++ CNpc::GetMap方法的具体用法?C++ CNpc::GetMap怎么用?C++ CNpc::GetMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNpc
的用法示例。
在下文中一共展示了CNpc::GetMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecvNpcDead
void CAISocket::RecvNpcDead(Packet & pkt)
{
uint16 nid = pkt.read<uint16>();
CNpc* pNpc = g_pMain->m_arNpcArray.GetData(nid);
if (pNpc == NULL)
return;
C3DMap* pMap = pNpc->GetMap();
if (pMap == NULL)
return;
if (pNpc->m_byObjectType == SPECIAL_OBJECT)
{
_OBJECT_EVENT *pEvent = pMap->GetObjectEvent(pNpc->m_sSid);
if (pEvent)
pEvent->byLife = 0;
}
pMap->RegionNpcRemove(pNpc->m_sRegion_X, pNpc->m_sRegion_Z, nid);
Packet result(WIZ_DEAD);
result << nid;
g_pMain->Send_Region(&result, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z);
pNpc->m_sRegion_X = pNpc->m_sRegion_Z = 0;
}
示例2: RecvNpcInfo
void CAISocket::RecvNpcInfo(Packet & pkt)
{
std::string strName;
uint8 Mode, byDirection;
uint16 sNid;
pkt.SByte();
pkt >> Mode >> sNid;
CNpc *pNpc = g_pMain->m_arNpcArray.GetData(sNid);
if (pNpc == NULL)
return;
pkt >> pNpc->m_sSid >> pNpc->m_sPid >> pNpc->m_sSize >> pNpc->m_iWeapon_1 >> pNpc->m_iWeapon_2
>> pNpc->m_bZone >> strName >> pNpc->m_bNation >> pNpc->m_bLevel
>> pNpc->m_curx >> pNpc->m_curz >> pNpc->m_cury >> byDirection >> pNpc->m_NpcState
>> pNpc->m_tNpcType >> pNpc->m_iSellingGroup >> pNpc->m_iMaxHP >> pNpc->m_iHP >> pNpc->m_byGateOpen
>> pNpc->m_sTotalHitrate >> pNpc->m_sTotalEvasionrate >> pNpc->m_sTotalAc >> pNpc->m_byObjectType
>> pNpc->m_byTrapNumber;
if (strName.empty() || strName.length() > MAX_NPC_SIZE)
{
pNpc->DecRef();
return;
}
pNpc->m_byDirection = byDirection;
strcpy(pNpc->m_strName, strName.c_str());
if (pNpc->GetMap() == NULL)
return;
pNpc->InsertRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ());
pNpc->SetRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ());
if (pNpc->m_byObjectType == SPECIAL_OBJECT)
{
_OBJECT_EVENT *pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid );
if (pEvent != NULL)
pEvent->byLife = 1;
}
if (Mode == 0)
{
TRACE("RecvNpcInfo - dead monster nid=%d, name=%s\n", pNpc->GetID(), pNpc->m_strName);
return;
}
pNpc->SendInOut(INOUT_IN, pNpc->GetX(), pNpc->GetZ(), pNpc->GetY());
}
示例3: RecvGateOpen
void CAISocket::RecvGateOpen( char* pBuf )
{
int index = 0, nNid = 0, nSid = 0, nGateFlag = 0;
CNpc* pNpc = NULL;
_OBJECT_EVENT* pEvent = NULL;
nNid = GetShort(pBuf, index);
nSid = GetShort(pBuf, index);
nGateFlag = GetByte(pBuf, index);
pNpc = m_pMain->m_arNpcArray.GetData(nNid);
if (pNpc == NULL)
{
TRACE("#### RecvGateOpen Npc Pointer null : nid=%d ####\n", nNid);
return;
}
pNpc->m_byGateOpen = nGateFlag; // possibly not needed (we'll do it below), but need to make sure.
pEvent = pNpc->GetMap()->GetObjectEvent(nSid);
if (pEvent == NULL)
{
TRACE("#### RecvGateOpen Npc Object fail : nid=%d, sid=%d ####\n", nNid, nSid);
return;
}
//TRACE("---> RecvGateOpen Npc Object fail : nid=%d, sid=%d, nGateFlag = %d ####\n", nNid, nSid, nGateFlag);
if (pNpc->isGate())
pNpc->SendGateFlag(nGateFlag, false);
}
示例4: RecvNpcDead
// TO-DO: Remove this. NPCs don't just randomly die, it would make sense to do this as a result of the cause, not just because.
void CAISocket::RecvNpcDead(Packet & pkt)
{
uint16 nid = pkt.read<uint16>();
CNpc* pNpc = g_pMain->m_arNpcArray.GetData(nid);
if (pNpc == NULL)
return;
C3DMap* pMap = pNpc->GetMap();
if (pMap == NULL)
return;
pNpc->OnDeath(NULL);
}
示例5: RecvNpcDead
// TO-DO: Remove this. NPCs don't just randomly die, it would make sense to do this as a result of the cause, not just because.
void CAISocket::RecvNpcDead(Packet & pkt)
{
CNpc * pNpc;
Unit * pAttacker;
uint16 nid, attackerID;
pkt >> nid >> attackerID;
pNpc = g_pMain->GetNpcPtr(nid);
if (pNpc == nullptr
|| pNpc->GetMap() == nullptr)
return;
pAttacker = g_pMain->GetUnitPtr(attackerID);
pNpc->OnDeath(pAttacker);
}
示例6: RecvNpcDead
void CAISocket::RecvNpcDead(char* pBuf)
{
int index = 0, send_index = 0;
int nid = 0;
char send_buff[256];
_OBJECT_EVENT* pEvent = NULL;
nid = GetShort(pBuf,index);
if(nid >= NPC_BAND) {
CNpc* pNpc = m_pMain->m_arNpcArray.GetData(nid);
if(!pNpc) return;
C3DMap* pMap = pNpc->GetMap();
if (pMap == NULL)
return;
if( pNpc->m_byObjectType == SPECIAL_OBJECT ) {
pEvent = pMap->GetObjectEvent( pNpc->m_sSid );
if( pEvent ) pEvent->byLife = 0;
}
//pNpc->NpcInOut( NPC_OUT );
//TRACE("RecvNpcDead - (%d,%s)\n", pNpc->m_sNid, pNpc->m_strName);
pMap->RegionNpcRemove(pNpc->m_sRegion_X, pNpc->m_sRegion_Z, nid);
//TRACE("--- RecvNpcDead : Npc를 Region에서 삭제처리.. ,, zone=%d, region_x=%d, y=%d\n", pNpc->m_sZoneIndex, pNpc->m_sRegion_X, pNpc->m_sRegion_Z);
SetByte( send_buff, WIZ_DEAD, send_index );
SetShort( send_buff, nid, send_index );
m_pMain->Send_Region(send_buff, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false);
pNpc->m_sRegion_X = 0; pNpc->m_sRegion_Z = 0;
}
}
示例7: RecvMagicAttackResult
void CAISocket::RecvMagicAttackResult(Packet & pkt)
{
uint32 magicid;
uint16 sid, tid;
uint8 byCommand;
/*
This is all so redundant...
When everything's switched over to pass in Packets
we can just pass it through directly!
As it is now.. we still need a length (which we can hardcode, but meh)
*/
pkt >> byCommand >> magicid >> sid >> tid;
if (byCommand == MAGIC_CASTING
|| (byCommand == MAGIC_EFFECTING && sid >= NPC_BAND && tid >= NPC_BAND))
{
CNpc *pNpc = g_pMain->m_arNpcArray.GetData(sid);
if (!pNpc)
return;
g_pMain->Send_Region(&pkt, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z);
}
else if (byCommand == MAGIC_EFFECTING)
{
if (sid >= USER_BAND && sid < NPC_BAND)
{
CUser *pUser = g_pMain->GetUserPtr(sid);
if (pUser == NULL || pUser->isDead())
return;
g_pMain->Send_Region(&pkt, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ);
return;
}
// If we're an NPC, casting a skill (rather, it's finished casting) on a player...
pkt.rpos(0);
m_MagicProcess.MagicPacket(pkt);
}
}
示例8: RecvNpcInfo
void CAISocket::RecvNpcInfo(Packet & pkt)
{
std::string strName;
uint8 Mode, byDirection;
uint16 sNid;
pkt.SByte();
pkt >> Mode >> sNid;
CNpc *pNpc = g_pMain->m_arNpcArray.GetData(sNid);
if (pNpc == NULL)
return;
pkt >> pNpc->m_sSid >> pNpc->m_sPid >> pNpc->m_sSize >> pNpc->m_iWeapon_1 >> pNpc->m_iWeapon_2
>> pNpc->m_bZoneID >> strName >> pNpc->m_byGroup >> pNpc->m_byLevel
>> pNpc->m_fCurX >> pNpc->m_fCurZ >> pNpc->m_fCurY >> byDirection >> pNpc->m_NpcState
>> pNpc->m_tNpcType >> pNpc->m_iSellingGroup >> pNpc->m_iMaxHP >> pNpc->m_iHP >> pNpc->m_byGateOpen
>> pNpc->m_sTotalHitrate >> pNpc->m_sTotalEvasionrate >> pNpc->m_sTotalAc >> pNpc->m_byObjectType;
if (strName.empty() || strName.length() > MAX_NPC_SIZE)
{
delete pNpc;
return;
}
pNpc->m_byDirection = byDirection;
strcpy(pNpc->m_strName, strName.c_str());
// Bug? Test?
// pNpc->m_NpcState = NPC_DEAD;
if (pNpc->m_NpcState == NPC_LIVE)
{
char strLog[256];
CTime t = CTime::GetCurrentTime();
sprintf_s(strLog, sizeof(strLog), "## time(%d:%d-%d) npc regen check(%d) : nid=%d, name=%s, x=%d, z=%d, rx=%d, rz=%d ## \r\n", t.GetHour(), t.GetMinute(), t.GetSecond(),
pNpc->m_NpcState, pNpc->GetID(), pNpc->m_strName, (int)pNpc->m_fCurX, (int)pNpc->m_fCurZ, pNpc->GetRegionX(), pNpc->GetRegionZ());
EnterCriticalSection( &g_LogFile_critical );
g_pMain->m_RegionLogFile.Write( strLog, strlen(strLog) );
LeaveCriticalSection( &g_LogFile_critical );
TRACE(strLog);
// to-do: replace with g_pMain->WriteRegionLog(...);
}
if (pNpc->GetMap() == NULL)
return;
pNpc->InsertRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ());
pNpc->SetRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ());
if (pNpc->m_byObjectType == SPECIAL_OBJECT)
{
_OBJECT_EVENT *pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid );
if (pEvent != NULL)
pEvent->byLife = 1;
}
if (Mode == 0)
{
TRACE("RecvNpcInfo - dead monster nid=%d, name=%s\n", pNpc->GetID(), pNpc->m_strName);
return;
}
pNpc->SendInOut(INOUT_IN, pNpc->GetX(), pNpc->GetZ(), pNpc->GetY());
}
示例9: RecvNpcInfoAll
void CAISocket::RecvNpcInfoAll(Packet & pkt)
{
uint8 bCount = pkt.read<uint8>(); // max of 20
pkt.SByte();
for (int i = 0; i < bCount; i++)
{
uint8 bType, bDirection;
std::string strName;
CNpc* pNpc = new CNpc();
pNpc->Initialize();
pkt >> bType >> pNpc->m_sNid >> pNpc->m_sSid >> pNpc->m_sPid >> pNpc->m_sSize >> pNpc->m_iWeapon_1 >> pNpc->m_iWeapon_2
>> pNpc->m_bZoneID >> strName >> pNpc->m_byGroup >> pNpc->m_byLevel >> pNpc->m_fCurX >> pNpc->m_fCurZ >> pNpc->m_fCurY
>> bDirection >> pNpc->m_tNpcType >> pNpc->m_iSellingGroup >> pNpc->m_iMaxHP >> pNpc->m_iHP >> pNpc->m_byGateOpen
>> pNpc->m_sTotalHitrate >> pNpc->m_sTotalEvasionrate >> pNpc->m_sTotalAc >> pNpc->m_byObjectType;
if (strName.empty() || strName.length() > MAX_NPC_SIZE)
{
delete pNpc;
continue;
}
//TRACE("Recv --> NpcUserInfo : uid = %d, x=%f, z=%f.. \n", nid, fPosX, fPosZ);
strcpy(pNpc->m_strName, strName.c_str());
pNpc->m_pMap = g_pMain->GetZoneByID(pNpc->GetZoneID());
pNpc->m_NpcState = NPC_LIVE;
pNpc->m_byDirection = bDirection;
pNpc->SetRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ());
if (pNpc->GetMap() == NULL)
{
delete pNpc;
pNpc = NULL;
continue;
}
if (pNpc->m_byObjectType == SPECIAL_OBJECT)
{
_OBJECT_EVENT* pEvent = pNpc->GetMap()->GetObjectEvent(pNpc->m_sSid);
if (pEvent != NULL)
pEvent->byLife = 1;
}
// TRACE("Recv --> NpcUserInfoAll : uid=%d, sid=%d, name=%s, x=%f, z=%f. gate=%d, objecttype=%d \n", nid, sPid, szName, fPosX, fPosZ, byGateOpen, byObjectType);
if (!g_pMain->m_arNpcArray.PutData(pNpc->GetID(), pNpc))
{
TRACE("Npc PutData Fail - %d\n", pNpc->GetID());
delete pNpc;
continue;
}
if (bType == 0)
{
TRACE("Recv --> NpcUserInfoAll : nid=%d, sid=%d, name=%s\n", pNpc->GetID(), pNpc->m_sSid, strName.c_str());
continue;
}
// RegionNpcAdd()
pNpc->SendInOut(INOUT_IN, pNpc->GetX(), pNpc->GetZ(), pNpc->GetY());
}
}
示例10: MagicSystem
void CUser::MagicSystem( Packet & pkt )
{
uint8 command, subcommand;
uint32 magicid;
time_t skill_received_time;
uint16 sid, tid, data1, data2, data3, data4, data5, data6, data7;
CUser *pUser, *pTargetUser = NULL;
CNpc *pMon = NULL;
skill_received_time = GetTickCount(); //Retrieve the time at which the Magic packet is going for internal processing.
command = pkt.GetOpcode();
pkt >> subcommand >> magicid >> sid >> tid;
if( sid < 0 || tid < 0 || tid > INVALID_BAND || sid != (uint16)GetSocketID()) //Return if there's an invalid source or target received.
return;
if( sid < MAX_USER )
{
if (isDead())
return;
}
if(tid >= NPC_BAND)
{
pMon = m_pMain->m_arNpcArray.GetData(tid);
if( !pMon || pMon->m_NpcState == NPC_DEAD )
return;
}
else if( tid < MAX_USER )
{
pTargetUser = m_pMain->GetUserPtr(tid);
if ( !pTargetUser )
return;
}
/*
Do ALL required pre-liminary checks here, will wrap that into another function, until then leaving this disabled.
*/
//if(!CheckSkillCooldown(magicid, skill_received_time)) //Check if the skill is off-cooldown.
// return;
//LogSkillCooldown(magicid, skill_received_time); Use this <if> the skill is successfully casted!
pkt >> data1 >> data2 >> data3 >> data4 >> data5 >> data6 >> data7;
switch(command)
{
case MAGIC_CASTING:
break;
case MAGIC_FLYING:
break;
case MAGIC_EFFECTING:
break;
case MAGIC_FAIL:
goto echo;
break;
case MAGIC_TYPE3_END: //This is also MAGIC_TYPE4_END
break;
case MAGIC_CANCEL:
break;
case MAGIC_CANCEL2:
break;
}
echo :
Packet result(WIZ_MAGIC_PROCESS);
result << subcommand << magicid << sid << tid << data1 << data2 << data3 << data4 << data5 << data6 << data7;
if (sid < MAX_USER)
{
m_pMain->Send_Region( &result, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ );
}
else if ( sid >= NPC_BAND)
{
m_pMain->Send_Region( &result, pMon->GetMap(), pMon->m_sRegion_X, pMon->m_sRegion_Z );
}
}
示例11: RecvNpcInfo
//.........这里部分代码省略.........
BYTE tNpcKind; // 00 : Monster
// 01 : NPC
int iSellingGroup;
int nMaxHP; // 최대 HP
int nHP; // 현재 HP
BYTE byGateOpen;
short sHitRate; // 공격 성공률
BYTE byObjectType; // 보통 : 0, 특수 : 1
Mode = GetByte(pBuf, index);
nid = GetShort(pBuf, index);
sid = GetShort(pBuf, index);
sPid = GetShort(pBuf, index);
sSize = GetShort(pBuf, index);
iWeapon_1 = GetDWORD(pBuf, index);
iWeapon_2 = GetDWORD(pBuf, index);
bZone = GetByte(pBuf, index);
int nLength = GetVarString(szName, pBuf, sizeof(BYTE), index);
if(nLength < 0 || nLength > MAX_NPC_SIZE) return; // 잘못된 monster 아이디
byGroup = GetByte(pBuf, index);
byLevel = GetByte(pBuf, index);
fPosX = Getfloat(pBuf, index);
fPosZ = Getfloat(pBuf, index);
fPosY = Getfloat(pBuf, index);
byDirection = GetByte(pBuf, index);
tState = GetByte(pBuf, index);
tNpcKind = GetByte(pBuf, index);
iSellingGroup = GetDWORD(pBuf, index);
nMaxHP = GetDWORD(pBuf, index);
nHP = GetDWORD(pBuf, index);
byGateOpen = GetByte(pBuf, index);
sHitRate = GetShort(pBuf, index);
byObjectType = GetByte(pBuf, index);
CNpc* pNpc = NULL;
pNpc = m_pMain->m_arNpcArray.GetData(nid);
if(!pNpc) return;
pNpc->m_NpcState = NPC_DEAD;
if( pNpc->m_NpcState == NPC_LIVE ) { // 살아 있는데 또 정보를 받는 경우
char strLog[256];
CTime t = CTime::GetCurrentTime();
sprintf_s(strLog, sizeof(strLog), "## time(%d:%d-%d) npc regen check(%d) : nid=%d, name=%s, x=%d, z=%d, rx=%d, rz=%d ## \r\n", t.GetHour(), t.GetMinute(), t.GetSecond(), pNpc->m_NpcState, nid, szName, (int)pNpc->m_fCurX, (int)pNpc->m_fCurZ, pNpc->m_sRegion_X, pNpc->m_sRegion_Z);
EnterCriticalSection( &g_LogFile_critical );
m_pMain->m_RegionLogFile.Write( strLog, strlen(strLog) );
LeaveCriticalSection( &g_LogFile_critical );
TRACE(strLog);
// to-do: replace with m_pMain->WriteRegionLog(...);
}
pNpc->m_NpcState = NPC_LIVE;
pNpc->m_sNid = nid;
pNpc->m_sSid = sid;
pNpc->m_sPid = sPid;
pNpc->m_sSize = sSize;
pNpc->m_iWeapon_1 = iWeapon_1;
pNpc->m_iWeapon_2 = iWeapon_2;
strcpy(pNpc->m_strName, szName);
pNpc->m_byGroup = byGroup;
pNpc->m_byLevel = byLevel;
pNpc->m_bCurZone = bZone;
pNpc->m_pMap = m_pMain->GetZoneByID(bZone);
pNpc->m_fCurX = fPosX;
pNpc->m_fCurZ = fPosZ;
pNpc->m_fCurY = fPosY;
pNpc->m_byDirection = byDirection;
pNpc->m_NpcState = tState;
pNpc->m_tNpcType = tNpcKind;
pNpc->m_iSellingGroup = iSellingGroup;
pNpc->m_iMaxHP = nMaxHP;
pNpc->m_iHP = nHP;
pNpc->m_byGateOpen = byGateOpen;
pNpc->m_sHitRate = sHitRate;
pNpc->m_byObjectType = byObjectType;
if (pNpc->GetMap() == NULL)
return;
int nRegX = (int)fPosX / VIEW_DISTANCE;
int nRegZ = (int)fPosZ / VIEW_DISTANCE;
pNpc->m_sRegion_X = nRegX;
pNpc->m_sRegion_Z = nRegZ;
_OBJECT_EVENT* pEvent = NULL;
if( pNpc->m_byObjectType == SPECIAL_OBJECT ) {
pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid );
if( pEvent ) pEvent->byLife = 1;
}
if(Mode == 0) {
TRACE("RecvNpcInfo - dead monster nid=%d, name=%s\n", pNpc->m_sNid, pNpc->m_strName);
return;
}
pNpc->NpcInOut(NPC_IN, fPosX, fPosZ, fPosY);
}
示例12: RecvMagicAttackResult
void CAISocket::RecvMagicAttackResult(char* pBuf)
{
int index = 0, send_index = 1, sid = -1, tid = -1, magicid=0;
BYTE byCommand;
short data0, data1, data2, data3, data4, data5;
CNpc* pNpc = NULL;
CUser* pUser = NULL;
char send_buff[1024];
//byType = GetByte(pBuf,index); // who ( 1:mon->user 2:mon->mon )
//byAttackType = GetByte(pBuf,index); // attack type ( 1:long attack, 2:magic attack
byCommand = GetByte(pBuf,index); // magic type ( 1:casting, 2:flying, 3:effecting, 4:fail )
magicid = GetDWORD(pBuf,index);
sid = GetShort(pBuf,index);
tid = GetShort(pBuf,index);
data0 = GetShort(pBuf,index);
data1 = GetShort(pBuf,index);
data2 = GetShort(pBuf,index);
data3 = GetShort(pBuf,index);
data4 = GetShort(pBuf,index);
data5 = GetShort(pBuf,index);
SetByte( send_buff, byCommand, send_index );
SetDWORD( send_buff, magicid, send_index );
SetShort( send_buff, sid, send_index );
SetShort( send_buff, tid, send_index );
SetShort( send_buff, data0, send_index );
SetShort( send_buff, data1, send_index );
SetShort( send_buff, data2, send_index );
SetShort( send_buff, data3, send_index );
SetShort( send_buff, data4, send_index );
SetShort( send_buff, data5, send_index );
if(byCommand == 0x01) { // casting
pNpc = m_pMain->m_arNpcArray.GetData(sid);
if(!pNpc) return;
index = 0;
SetByte( send_buff, WIZ_MAGIC_PROCESS, index );
m_pMain->Send_Region(send_buff, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false);
}
else if(byCommand == 0x03) { // effecting
//pNpc = m_pMain->m_arNpcArray.GetData(tid);
//if(!pNpc) return;
if( sid >= USER_BAND && sid < NPC_BAND) {
pUser = m_pMain->GetUserPtr(sid);
if (pUser == NULL || pUser->isDead())
return;
index = 0;
SetByte( send_buff, WIZ_MAGIC_PROCESS, index );
m_pMain->Send_Region(send_buff, send_index, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ, NULL, false);
}
else if(sid >= NPC_BAND) {
if(tid >= NPC_BAND) {
pNpc = m_pMain->m_arNpcArray.GetData(tid);
if(!pNpc) return;
index = 0;
SetByte( send_buff, WIZ_MAGIC_PROCESS, index );
m_pMain->Send_Region(send_buff, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false);
return;
}
send_index = 0;
SetByte( send_buff, byCommand, send_index );
SetDWORD( send_buff, magicid, send_index );
SetShort( send_buff, sid, send_index );
SetShort( send_buff, tid, send_index );
SetShort( send_buff, data0, send_index );
SetShort( send_buff, data1, send_index );
SetShort( send_buff, data2, send_index );
SetShort( send_buff, data3, send_index );
SetShort( send_buff, data4, send_index );
SetShort( send_buff, data5, send_index );
m_MagicProcess.MagicPacket(send_buff, send_index);
}
}
}
示例13: RecvNpcAttack
void CAISocket::RecvNpcAttack(char* pBuf)
{
int index = 0, send_index = 0, sid = -1, tid = -1, nHP = 0, temp_damage = 0;
BYTE type, result, byAttackType = 0;
float fDir=0.0f;
short damage = 0;
CNpc* pNpc = NULL, *pMon = NULL;
CUser* pUser = NULL;
char pOutBuf[1024];
_OBJECT_EVENT* pEvent = NULL;
type = GetByte(pBuf,index);
result = GetByte(pBuf,index);
sid = GetShort(pBuf,index);
tid = GetShort(pBuf,index);
damage = GetShort(pBuf,index);
nHP = GetDWORD(pBuf,index);
byAttackType = GetByte(pBuf, index);
//TRACE("CAISocket-RecvNpcAttack : sid=%s, tid=%d, zone_num=%d\n", sid, tid, m_iZoneNum);
if(type == 0x01) // user attack -> npc
{
pNpc = m_pMain->m_arNpcArray.GetData(tid);
if(!pNpc) return;
pNpc->m_iHP -= damage;
if( pNpc->m_iHP < 0 )
pNpc->m_iHP = 0;
if(result == 0x04) { // 마법으로 죽는경우
SetByte( pOutBuf, WIZ_DEAD, send_index );
SetShort( pOutBuf, tid, send_index );
m_pMain->Send_Region(pOutBuf, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false);
}
else {
SetByte(pOutBuf, WIZ_ATTACK, send_index);
SetByte( pOutBuf, byAttackType, send_index ); // 직접:1, 마법:2, 지속마법:3
//if(result == 0x04) // 마법으로 죽는경우
// SetByte( pOutBuf, 0x02, send_index );
//else // 단순공격으로 죽는경우
SetByte( pOutBuf, result, send_index );
SetShort( pOutBuf, sid, send_index );
SetShort( pOutBuf, tid, send_index );
m_pMain->Send_Region(pOutBuf, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false);
}
pUser = m_pMain->GetUserPtr(sid);
if (pUser != NULL)
{
pUser->SendTargetHP( 0, tid, -damage );
if( byAttackType != MAGIC_ATTACK && byAttackType != DURATION_ATTACK) {
pUser->ItemWoreOut(ATTACK, damage);
// LEFT HAND!!! by Yookozuna
temp_damage = damage * pUser->m_bMagicTypeLeftHand / 100 ;
switch (pUser->m_bMagicTypeLeftHand) { // LEFT HAND!!!
case ITEM_TYPE_HP_DRAIN : // HP Drain
pUser->HpChange(temp_damage, 0);
break;
case ITEM_TYPE_MP_DRAIN : // MP Drain
pUser->MSpChange(temp_damage);
break;
}
temp_damage = 0; // reset data;
// RIGHT HAND!!! by Yookozuna
temp_damage = damage * pUser->m_bMagicTypeRightHand / 100 ;
switch (pUser->m_bMagicTypeRightHand) { // LEFT HAND!!!
case ITEM_TYPE_HP_DRAIN : // HP Drain
pUser->HpChange(temp_damage, 0);
break;
case ITEM_TYPE_MP_DRAIN : // MP Drain
pUser->MSpChange(temp_damage);
break;
}
//
}
}
if(result == 0x02 || result == 0x04) // npc dead
{
pNpc->GetMap()->RegionNpcRemove(pNpc->m_sRegion_X, pNpc->m_sRegion_Z, tid);
// TRACE("--- Npc Dead : Npc를 Region에서 삭제처리.. ,, region_x=%d, y=%d\n", pNpc->m_sRegion_X, pNpc->m_sRegion_Z);
pNpc->m_sRegion_X = 0; pNpc->m_sRegion_Z = 0;
pNpc->m_NpcState = NPC_DEAD;
if( pNpc->m_byObjectType == SPECIAL_OBJECT ) {
pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid );
if( pEvent ) pEvent->byLife = 0;
}
if (pNpc->m_tNpcType == 2 && pUser != NULL) // EXP
pUser->GiveItem(900001000, 1);
}
}
//.........这里部分代码省略.........
示例14: RecvNpcInfoAll
//.........这里部分代码省略.........
sid = GetShort(pBuf, index);
sPid = GetShort(pBuf, index);
sSize = GetShort(pBuf, index);
iweapon_1 = GetDWORD(pBuf, index);
iweapon_2 = GetDWORD(pBuf, index);
bZone = GetByte(pBuf, index);
int nLength = GetVarString(szName, pBuf, sizeof(BYTE), index);
byGroup = GetByte(pBuf, index);
byLevel = GetByte(pBuf, index);
fPosX = Getfloat(pBuf, index);
fPosZ = Getfloat(pBuf, index);
fPosY = Getfloat(pBuf, index);
byDirection = GetByte(pBuf, index);
tNpcType = GetByte(pBuf, index);
iSellingGroup = GetDWORD(pBuf, index);
nMaxHP = GetDWORD(pBuf, index);
nHP = GetDWORD(pBuf, index);
byGateOpen = GetByte(pBuf, index);
sHitRate = GetShort(pBuf, index);
byObjectType = GetByte(pBuf, index);
//TRACE("RecvNpcInfoAll : nid=%d, szName=%s, count=%d\n", nid, szName, byCount);
if(nLength < 0 || nLength > MAX_NPC_SIZE) {
TRACE("#### RecvNpcInfoAll Fail : szName=%s\n", szName);
continue; // 잘못된 monster 아이디
}
//TRACE("Recv --> NpcUserInfo : uid = %d, x=%f, z=%f.. \n", nid, fPosX, fPosZ);
CNpc* pNpc = NULL;
pNpc = new CNpc;
if(pNpc == NULL) {
TRACE("#### Recv --> NpcUserInfoAll POINT Fail: uid=%d, sid=%d, name=%s, zone=%d, x=%f, z=%f.. \n", nid, sPid, szName, bZone, fPosX, fPosZ);
continue;
}
pNpc->Initialize();
pNpc->m_sNid = nid;
pNpc->m_sSid = sid;
pNpc->m_sPid = sPid;
pNpc->m_sSize = sSize;
pNpc->m_iWeapon_1 = iweapon_1;
pNpc->m_iWeapon_2 = iweapon_2;
strcpy(pNpc->m_strName, szName);
pNpc->m_byGroup = byGroup;
pNpc->m_byLevel = byLevel;
pNpc->m_bCurZone = bZone;
pNpc->m_pMap = m_pMain->GetZoneByID(bZone);
pNpc->m_fCurX = fPosX;
pNpc->m_fCurZ = fPosZ;
pNpc->m_fCurY = fPosY;
pNpc->m_byDirection = byDirection;
pNpc->m_NpcState = NPC_LIVE;
pNpc->m_tNpcType = tNpcType;
pNpc->m_iSellingGroup = iSellingGroup;
pNpc->m_iMaxHP = nMaxHP;
pNpc->m_iHP = nHP;
pNpc->m_byGateOpen = byGateOpen;
pNpc->m_sHitRate = sHitRate;
pNpc->m_byObjectType = byObjectType;
pNpc->m_NpcState = NPC_LIVE;
int nRegX = (int)fPosX / VIEW_DISTANCE;
int nRegZ = (int)fPosZ / VIEW_DISTANCE;
pNpc->m_sRegion_X = nRegX;
pNpc->m_sRegion_Z = nRegZ;
if (pNpc->GetMap() == NULL)
{
delete pNpc;
pNpc = NULL;
continue;
}
_OBJECT_EVENT* pEvent = NULL;
if (pNpc->m_byObjectType == SPECIAL_OBJECT)
{
pEvent = pNpc->GetMap()->GetObjectEvent(pNpc->m_sSid);
if( pEvent ) pEvent->byLife = 1;
}
// TRACE("Recv --> NpcUserInfoAll : uid=%d, sid=%d, name=%s, x=%f, z=%f. gate=%d, objecttype=%d \n", nid, sPid, szName, fPosX, fPosZ, byGateOpen, byObjectType);
if( !m_pMain->m_arNpcArray.PutData( pNpc->m_sNid, pNpc) ) {
TRACE("Npc PutData Fail - %d\n", pNpc->m_sNid);
delete pNpc;
pNpc = NULL;
continue;
}
if( byType == 0 ) {
TRACE("Recv --> NpcUserInfoAll : 등록하면 안돼여,, uid=%d, sid=%d, name=%s\n", nid, sPid, szName);
continue; // region에 등록하지 말기...
}
pNpc->GetMap()->RegionNpcAdd(pNpc->m_sRegion_X, pNpc->m_sRegion_Z, pNpc->m_sNid);
}
}
示例15: RecvNpcInfoAll
void CAISocket::RecvNpcInfoAll(Packet & pkt)
{
uint8 bCount = pkt.read<uint8>(); // max of 20
pkt.SByte();
for (int i = 0; i < bCount; i++)
{
uint8 bDirection;
std::string strName;
CNpc* pNpc = new CNpc();
pNpc->Initialize();
pkt >> pNpc->m_NpcState >> pNpc->m_sNid >> pNpc->m_sSid >> pNpc->m_sPid >> pNpc->m_sSize >> pNpc->m_iWeapon_1 >> pNpc->m_iWeapon_2
>> pNpc->m_bZone >> strName >> pNpc->m_bNation >> pNpc->m_bLevel
>> pNpc->m_curx >> pNpc->m_curz >> pNpc->m_cury >> bDirection
>> pNpc->m_tNpcType >> pNpc->m_iSellingGroup >> pNpc->m_iMaxHP >> pNpc->m_iHP >> pNpc->m_byGateOpen
>> pNpc->m_fTotalHitrate >> pNpc->m_fTotalEvasionrate
>> pNpc->m_sTotalAc >> pNpc->m_sTotalHit
>> pNpc->m_byObjectType
>> pNpc->m_byTrapNumber >> pNpc->m_bMonster
>> pNpc->m_sFireR >> pNpc->m_sColdR >> pNpc->m_sLightningR
>> pNpc->m_sMagicR >> pNpc->m_sDiseaseR >> pNpc->m_sPoisonR;
if (strName.empty())
strName = "<the spawn with no name>";
if (strName.length() > MAX_NPC_SIZE)
{
pNpc->DecRef();
continue;
}
pNpc->m_pMap = g_pMain->GetZoneByID(pNpc->GetZoneID());
if (pNpc->GetMap() == nullptr)
{
pNpc->DecRef();
continue;
}
//TRACE("Recv --> NpcUserInfo : uid = %d, x=%f, z=%f.. \n", nid, fPosX, fPosZ);
pNpc->m_strName = strName;
pNpc->m_byDirection = bDirection;
pNpc->SetRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ());
if (pNpc->m_byObjectType == SPECIAL_OBJECT)
{
_OBJECT_EVENT* pEvent = pNpc->GetMap()->GetObjectEvent(pNpc->m_sSid);
if (pEvent != nullptr)
pEvent->byLife = 1;
}
// TRACE("Recv --> NpcUserInfoAll : uid=%d, sid=%d, name=%s, x=%f, z=%f. gate=%d, objecttype=%d \n", nid, sPid, szName, fPosX, fPosZ, byGateOpen, byObjectType);
if (!g_pMain->m_arNpcArray.PutData(pNpc->GetID(), pNpc))
{
TRACE("Npc PutData Fail - %d\n", pNpc->GetID());
pNpc->DecRef();
continue;
}
if (pNpc->m_NpcState == NPC_DEAD)
{
TRACE("Recv --> NpcUserInfoAll : nid=%d, sid=%d, name=%s\n", pNpc->GetID(), pNpc->m_sSid, strName.c_str());
continue;
}
pNpc->SendInOut(INOUT_IN, pNpc->GetX(), pNpc->GetZ(), pNpc->GetY());
}
}