void CMagicProcess::MagicPacket(Packet & pkt) { int magicid = 0; int16 sid, tid; uint16 data1 = 0, data2 = 0, data3 = 0, data4 = 0, data5 = 0, data6 = 0, TotalDex=0, righthand_damage = 0, result = 1; _MAGIC_TABLE* pTable = nullptr; sid = m_pSrcUser->m_iUserId; uint8 command = pkt.read<uint8>(); pkt >> tid >> magicid >> data1 >> data2 >> data3 >> data4 >> data5 >> data6 >> TotalDex >> righthand_damage; //TRACE("MagicPacket - command=%d, tid=%d, magicid=%d\n", command, tid, magicid); pTable = IsAvailable( magicid, tid, command ); // If magic was successful....... if( !pTable ) return; if( command == MAGIC_EFFECTING ) // Is target another player? { switch( pTable->bType[0] ) { case 1: result = ExecuteType1( pTable->iNum, tid, data1, data2, data3, 1 ); break; case 2: result = ExecuteType2( pTable->iNum, tid, data1, data2, data3 ); break; case 3: ExecuteType3( pTable->iNum, tid, data1, data2, data3, pTable->bMoral, TotalDex, righthand_damage ); break; case 4: ExecuteType4( pTable->iNum, sid, tid, data1, data2, data3, pTable->bMoral ); break; } if(result != 0) { switch( pTable->bType[1] ) { case 1: ExecuteType1( pTable->iNum, tid, data4, data5, data6, 2 ); break; case 2: ExecuteType2( pTable->iNum, tid, data1, data2, data3 ); break; case 3: ExecuteType3( pTable->iNum, tid, data1, data2, data3, pTable->bMoral, TotalDex, righthand_damage ); break; case 4: ExecuteType4( pTable->iNum, sid, tid, data1, data2, data3, pTable->bMoral ); break; } } } }
void CNpcMagicProcess::MagicPacket(char *pBuf, int len) { int index = 0, send_index = 0, magicid = 0, sid = -1, tid = -1, data1 = 0, data2 = 0, data3 = 0, data4 = 0, data5 = 0, data6 = 0; char send_buff[128]; _MAGIC_TABLE* pTable = NULL; BYTE command = GetByte( pBuf, index ); // Get the magic status. if( command == MAGIC_FAIL ) { // Client indicates that magic failed. Just send back packet. SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetString( send_buff, pBuf, len-1, send_index ); // len ==> include WIZ_MAGIC_PROCESS command byte. //g_pMain->Send_Region( send_buff, send_index, m_pSrcUser->m_pUserData->m_bZone, m_pSrcUser->m_RegionX, m_pSrcUser->m_RegionZ ); m_bMagicState = NONE; return; } magicid = GetDWORD( pBuf, index ); // Get ID of magic. sid = GetShort( pBuf, index ); // Get ID of source. tid = GetShort( pBuf, index ); // Get ID of target. data1 = GetShort( pBuf, index ); // ( Remember, you don't definately need this. ) data2 = GetShort( pBuf, index ); // ( Only use it when you really feel it's needed. ) data3 = GetShort( pBuf, index ); data4 = GetShort( pBuf, index ); data5 = GetShort( pBuf, index ); data6 = GetShort( pBuf, index ); // Get data1 ~ data6 (No, I don't know what the hell 'data' is.) pTable = IsAvailable( magicid, tid, command ); // If magic was successful....... if( !pTable ) return; if( command == MAGIC_EFFECTING ) // Is target another player? { //if (tid < -1 || tid >= MAX_USER) return; switch( pTable->bType[0] ) { case 1: ExecuteType1( pTable->iNum, tid, data1, data2, data3 ); break; case 2: ExecuteType2( pTable->iNum, tid, data1, data2, data3 ); break; case 3: ExecuteType3( pTable->iNum, tid, data1, data2, data3, pTable->bMoral ); break; case 4: ExecuteType4( pTable->iNum, tid ); break; case 5: ExecuteType5( pTable->iNum ); break; case 6: ExecuteType6( pTable->iNum ); break; case 7: ExecuteType7( pTable->iNum ); break; case 8: ExecuteType8( pTable->iNum, tid, sid, data1, data2, data3 ); break; case 9: ExecuteType9( pTable->iNum ); break; case 10: ExecuteType10( pTable->iNum ); break; } switch( pTable->bType[1] ) { case 1: ExecuteType1( pTable->iNum, tid, data4, data5, data6 ); break; case 2: ExecuteType2( pTable->iNum, tid, data1, data2, data3 ); break; case 3: ExecuteType3( pTable->iNum, tid, data1, data2, data3, pTable->bMoral ); break; case 4: ExecuteType4( pTable->iNum, tid ); break; case 5: ExecuteType5( pTable->iNum ); break; case 6: ExecuteType6( pTable->iNum ); break; case 7: ExecuteType7( pTable->iNum ); break; case 8: ExecuteType8( pTable->iNum, tid, sid, data1, data2, data3 ); break; case 9: ExecuteType9( pTable->iNum ); break; case 10: ExecuteType10( pTable->iNum ); break; } } else if( command == MAGIC_CASTING ) { SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetString( send_buff, pBuf, len-1, send_index ); // len ==> include WIZ_MAGIC_PROCESS command byte. m_pSrcNpc->SendAll(send_buff, send_index); } }