[HELP]Magicattack Packet

06/22/2015 16:31 xmen01235V2#1
Its been so long that I have never played around with conquer packet and I forget already if what does this part of the packet means.

2C 00 - Packet Length
FE 03 - Packet ID
CC E8 C9 00 - Timer
CC E8 C9 00 - Timer2
BE FF 2F 00 - Character ID
73 65 2F B2 - Target ID
A3 40 - AimX
69 F2 - AimY
18 00 00 00 - Action Type
AD 2D - Skill ID
21 FB - ????? (<------------------)
00 00 00 00 00 00 00 00 00 00 00 00 54 51 43 6C 69 65 6E 74
06/22/2015 18:15 phize#2
Offset 28 is magic type, 30 is magic level. That is, on retail.
06/23/2015 02:03 xmen01235V2#3
Quote:
Originally Posted by phize View Post
Offset 28 is magic type, 30 is magic level. That is, on retail.
Hi thanks appreciate your help. I noticed that it changes its value randomly and it seems it is coded with the timer. By chance do you know how to decode and encode it?
06/23/2015 03:21 phize#4
Quote:
Originally Posted by xmen01235V2 View Post
Hi thanks appreciate your help. I noticed that it changes its value randomly and it seems it is coded with the timer. By chance do you know how to decode and encode it?
From Eudemons:

Code:
inline unsigned int	ExchangeShortBits(unsigned long nData, int nBits)
{
	MYASSERT(nBits >= 0 && nBits < 16);
	nData	&= 0xFFFF;
	return ((nData>>nBits) | (nData<<(16-nBits))) & 0xFFFF;
}
inline unsigned int	ExchangeLongBits(unsigned long nData, int nBits)
{
	MYASSERT(nBits >= 0 && nBits < 32);
	return (nData>>nBits) | (nData<<(32-nBits));
}
Code:
#define	ENCODE_MAGICATTACK(idUser,usType,idTarget,usPosX,usPosY) {	\
				usType		= (::ExchangeShortBits((usType - 0x14BE),3) ^ (idUser) ^ 0x915D);	\
				idTarget	= ::ExchangeLongBits(((idTarget - 0x8B90B51A) ^ (idUser) ^ 0x5F2D2463),32-13); \
				usPosX		= (::ExchangeShortBits((usPosX - 0xDD12),1) ^ (idUser) ^ 0x2ED6);	\
                usPosY		= (::ExchangeShortBits((usPosY - 0x76DE),5) ^ (idUser) ^ 0xB99B);	}

#define	DECODE_MAGICATTACK(idUser,usType,idTarget,usPosX,usPosY) {	\
				usType		= 0xFFFF&(::ExchangeShortBits(((usType) ^ (idUser) ^ 0x915D),16-3) + 0x14BE);	\
				idTarget	= (::ExchangeLongBits((idTarget),13) ^ (idUser) ^ 0x5F2D2463) + 0x8B90B51A; \
				usPosX		= 0xFFFF&(::ExchangeShortBits(((usPosX) ^ (idUser) ^ 0x2ED6),16-1) + 0xDD12);	\
                usPosY		= 0xFFFF&(::ExchangeShortBits(((usPosY) ^ (idUser) ^ 0xB99B),16-5) + 0x76DE);	}
06/23/2015 04:51 xmen01235V2#5
Quote:
Originally Posted by phize View Post
From Eudemons:

Code:
inline unsigned int	ExchangeShortBits(unsigned long nData, int nBits)
{
	MYASSERT(nBits >= 0 && nBits < 16);
	nData	&= 0xFFFF;
	return ((nData>>nBits) | (nData<<(16-nBits))) & 0xFFFF;
}
inline unsigned int	ExchangeLongBits(unsigned long nData, int nBits)
{
	MYASSERT(nBits >= 0 && nBits < 32);
	return (nData>>nBits) | (nData<<(32-nBits));
}
Code:
#define	ENCODE_MAGICATTACK(idUser,usType,idTarget,usPosX,usPosY) {	\
				usType		= (::ExchangeShortBits((usType - 0x14BE),3) ^ (idUser) ^ 0x915D);	\
				idTarget	= ::ExchangeLongBits(((idTarget - 0x8B90B51A) ^ (idUser) ^ 0x5F2D2463),32-13); \
				usPosX		= (::ExchangeShortBits((usPosX - 0xDD12),1) ^ (idUser) ^ 0x2ED6);	\
                usPosY		= (::ExchangeShortBits((usPosY - 0x76DE),5) ^ (idUser) ^ 0xB99B);	}

#define	DECODE_MAGICATTACK(idUser,usType,idTarget,usPosX,usPosY) {	\
				usType		= 0xFFFF&(::ExchangeShortBits(((usType) ^ (idUser) ^ 0x915D),16-3) + 0x14BE);	\
				idTarget	= (::ExchangeLongBits((idTarget),13) ^ (idUser) ^ 0x5F2D2463) + 0x8B90B51A; \
				usPosX		= 0xFFFF&(::ExchangeShortBits(((usPosX) ^ (idUser) ^ 0x2ED6),16-1) + 0xDD12);	\
                usPosY		= 0xFFFF&(::ExchangeShortBits(((usPosY) ^ (idUser) ^ 0xB99B),16-5) + 0x76DE);	}
Thanks mate :). But it seems that the magiclevel is not included on that chunk of codes yet.
06/23/2015 12:45 phize#6
Quote:
Originally Posted by xmen01235V2 View Post
Thanks mate :). But it seems that the magiclevel is not included on that chunk of codes yet.
My bad. Just have a look at any of the more recent pserver sources, they should have it implemented.
06/23/2015 14:19 { Angelius }#7
Encoding: (1 + 0x100 * (TimeStamp % 0x100) ^ 0x3721)

Decoding is your Homework.
06/23/2015 16:27 xmen01235V2#8
Thanks a lot guys. I saw the complete routine also while digging in the pserver source. Just need to try it later when I will arrive home :) .

Quote:
Originally Posted by { Angelius } View Post
Encoding: (1 + 0x100 * (TimeStamp % 0x100) ^ 0x3721)

Decoding is your Homework.
This should be the decoding right?

Code:
(ushort)(_mypacket.ReadUshort(30)  ^ 0x21)