PDA

View Full Version : |Source| Right Click Mouse para main 1.04E



Goten
29/05/2020, 07:00 PM
[Only registered and activated users can see links]

//================ Client =======================

Import.h

#define pChaosBoxState *(BYTE*)(*(DWORD*)(0x98670C4) + 0xC8)

post_item.cpp

PostItem::PostItem ()

#if(MOVE_ITEM)
last_tickcount_moveitem_ = 0;
#endif


void PostItem::Hook()
#if(MOVE_ITEM)
SetCompleteHook(0xE9, 0x0083B7E4 + 0x150, &Equipments);//1.04D->0x0083B7E4
#endif


#if(MOVE_ITEM)
void __declspec (naked) PostItem::Equipments() {
static DWORD mem = 0;
_asm {
mov eax, dword ptr ds : [ebp - 04]
mov mem, eax
}
RemoveEquipment((void *)mem);
_asm {
mov esp, ebp
pop ebp
ret 0004
}
}
void PostItem::RemoveEquipment(void * item_data) {
// check window, not allow for shop, inventory, warehouse, etc
if (gInterface.CheckWindow(Trade) ||
gInterface.CheckWindow(Warehouse) ||
gInterface.CheckWindow(Shop) ||
gInterface.CheckWindow(Store) ||
gInterface.CheckWindow(OtherStore) ||
gInterface.CheckWindow(CashShop) ||
gInterface.CheckWindow(ExpandWarehouse)) {
return;
}
if (GetKeyState(VK_RBUTTON) & 0x8000 && GetTickCount() >= gPostItem.last_tickcount_moveitem_ + 250) {

ObjectItem * lItem = (ObjectItem*)item_data;

if (lItem->ItemID < 0) { return; }

PMSG_ITEM_MOVE_RECV pMsg = { 0 };

pMsg.h.set(0x79, 0x01, sizeof(pMsg));

pMsg.sFlag = 0;
pMsg.tFlag = 0;
pMsg.Source = lItem->PosX;
pMsg.Target = 0;

DataSend((BYTE*)&pMsg, pMsg.h.size);

gPostItem.last_tickcount_moveitem_ = GetTickCount();
}
}
#endif



void PostItem::PostItemToWorldChatChannelImp ( void * item_data ) {
// check window, not allow for shop, inventory, warehouse, etc
if ( gInterface.CheckWindow ( Trade ) ||
gInterface.CheckWindow ( Warehouse ) ||
gInterface.CheckWindow ( Shop ) ||
gInterface.CheckWindow ( Store ) ||
gInterface.CheckWindow ( OtherStore ) ||
gInterface.CheckWindow ( CashShop ) ||
gInterface.CheckWindow ( ExpandWarehouse ) ) {
return;
}

if ( GetTickCount() <= gPostItem.last_tickcount_post_ + 3000 ) { return; }

if ( GetKeyState ( VK_RBUTTON ) & 0x8000 && GetKeyState ( VK_CONTROL ) & 0x8000 ) {
PMSG_POSTITEM iMsg = { '\0' };
strcpy_s ( iMsg.chatmsg, ( char* ) pCurrentViewingItemName );
memcpy_s ( &iMsg.chatid[0], 10, ( char* ) oUserObjectStruct_, 10 );
memcpy_s ( &iMsg.item_data[0], 107, item_data, 107 );
iMsg.header.set ( ( LPBYTE ) &iMsg, 0x78, sizeof ( iMsg ) );
DataSend2 ( ( LPBYTE ) &iMsg, iMsg.header.size );
gPostItem.last_tickcount_post_ = GetTickCount();
}
#if(MOVE_ITEM)
else if (GetKeyState(VK_RBUTTON) & 0x8000 && GetTickCount() >= gPostItem.last_tickcount_moveitem_ + 250) {

ObjectItem * lItem = (ObjectItem*)item_data;

if (lItem->ItemID < 0) { return; }

PMSG_ITEM_MOVE_RECV pMsg = { 0 };

pMsg.h.set(0x79, 0x01, sizeof(pMsg));
pMsg.Target = -1;

if (gInterface.CheckWindow(ChaosBox) && gInterface.CheckWindow(Inventory)) {
if ((pCursorX > 460))
{
pMsg.sFlag = 0;
pMsg.tFlag = 3;
pMsg.Target = 0;
pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12;
}
else if (gInterface.CheckWindow(ExpandInventory) && pCursorX > 260)
{
pMsg.sFlag = 0;
pMsg.tFlag = 3;
pMsg.Target = 0;
pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12 + 64;
if (pCursorY > 130)
pMsg.Source += 32;
}
else {
pMsg.sFlag = 3;
pMsg.tFlag = 0;
pMsg.Target = 0;
pMsg.Source = lItem->PosX + lItem->PosY * 8;
}
}
else {
float v1 = 0;
if (gInterface.CheckWindow(Character))
v1 = *(float*)(0x00D24E88);
if ((pCursorX > 460 - v1))
{
pMsg.sFlag = 0;
pMsg.tFlag = 0;
pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12;

}
else if (gInterface.CheckWindow(ExpandInventory) && pCursorX > 260 - v1)
{
pMsg.sFlag = 0;
pMsg.tFlag = 0;
pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12 + 64;
if (pCursorY > 130)
pMsg.Source += 32;
}
pMsg.Target = 0;
}

DataSend((BYTE*)&pMsg, pMsg.h.size);
gPostItem.last_tickcount_moveitem_ = GetTickCount();
}
#endif

post_item.h


#if(MOVE_ITEM)
static void Equipments();
static void RemoveEquipment(void * item_data);
#endif

private:

#if(MOVE_ITEM)
DWORD last_tickcount_moveitem_;
#endif


Protocol.cpp

#if(MOVE_ITEM)
case 0xEE:
SetChaosBoxState((PMSG_SET_CHAOSBOX_STATE*)lpMsg);
return 1;
#endif



#if(MOVE_ITEM)
void SetChaosBoxState(PMSG_SET_CHAOSBOX_STATE* Data){
pChaosBoxState = Data->state;
return;
}
#endif


Protocol.h


#if(MOVE_ITEM)
struct PMSG_ITEM_MOVE_RECV
{
PSBMSG_HEAD h;
BYTE sFlag;
BYTE tFlag;
BYTE Source;
BYTE Target;
};

#if(MOVE_ITEM)
void SetChaosBoxState(PMSG_SET_CHAOSBOX_STATE* Data);
#endif


//================ Server =======================


ItemMannager.cpp

#if(MOVE_ITEM)
BYTE CItemManager::InventoryCheckInsertItem(int aIndex, WORD item) // OK
{
ITEM_INFO ItemInfo;

if (this->GetInfo(item, &ItemInfo) == 0)
{
return 0xFF;
}

int MaxY = (this->GetInventoryMaxValue(&gObj[aIndex]) - INVENTORY_WEAR_SIZE) / 8;

for (int y = 0; y < MaxY; y++)
{
for (int x = 0; x < 8; x++)
{
if (gObj[aIndex].InventoryMap[((y * 8) + x)] == 0xFF) // y * 8
{
BYTE slot = this->InventoryRectCheck(aIndex, x, y, ItemInfo.Width, ItemInfo.Height);

if (slot != 0xFF)
{
return slot;
}
}
}
}

return 0xFF;
}
#endif



#if(MOVE_ITEM)
void CItemManager::CGMoveItemProc(PMSG_MOVEITEM* aRecv, short aIndex) {

if (OBJMAX_RANGE(aIndex) == 0) { return; }


LPOBJ lpObj = &gObj[aIndex];


if (aRecv->Target == -1) { return; }


if (aRecv->tFlag == 3 & aRecv->sFlag == 0 && lpObj->Inventory[aRecv->Source].IsItem()) //check input item
{
if (IsLuckyItem(lpObj->Inventory[aRecv->Source].m_Index))
{
return;
}

BYTE btItemType = 0;
btItemType |= (lpObj->Inventory[aRecv->Source].m_Index & 0x1E00) >> 5;

if ((btItemType + 2) == lpObj->Inventory[aRecv->Source].m_ItemOptionEx)
{
return;
}
}


PMSG_ITEM_MOVE_RECV pMsg = { 0 };

pMsg.TargetSlot = -1;

if (aRecv->tFlag == 3 & aRecv->sFlag == 0) //move Inv -> ChaosBox
{
if (!lpObj->Inventory[aRecv->Source].IsItem())
return; //no item
int p = 0, c = 0, d = 0, w = 0, h = 0, n = 0;
int Target = -1;
int TargetMap[CHAOS_BOX_SIZE] = { '\0' };

ITEM_INFO ItemInfo;

for (n = 0; n < CHAOS_BOX_SIZE; n++) {
if (lpObj->ChaosBox[n].IsItem()) {
if (this->GetInfo(lpObj->ChaosBox[n].m_Index, &ItemInfo) == 0)
{
return; //invalid item.
}
w = ItemInfo.Width;
h = ItemInfo.Height;

for (c = 0; c < w; c++) {
for (d = 0; d < h; d++) {
p = c + d * 8 + n;
if (p < CHAOS_BOX_SIZE) {
TargetMap[p] = 1;
}
}
}
}
}

for (n = 0; n < CHAOS_BOX_SIZE; n++) {
if (!TargetMap[n]) {
Target = n;
if (this->GetInfo(lpObj->Inventory[aRecv->Source].m_Index, &ItemInfo) == 0)
{
return; //invalid item.
}
w = ItemInfo.Width;
h = ItemInfo.Height;
for (c = 0; c < w; c++) {
for (d = 0; d < h; d++) {
p = c + d * 8 + n;
if (p >= CHAOS_BOX_SIZE || TargetMap[p] || (n % 8) + c > 7) // 8) = 8
{
Target = -1;
}
}
}
if (Target != -1)
break;
}
}
if (Target != -1)
{
pMsg.TargetSlot = Target;
this->ItemByteConvert(pMsg.ItemInfo, lpObj->Inventory[aRecv->Source]);
}
else {
return; //no more empty slot to add.
}
}
else if (aRecv->tFlag == 0 & aRecv->sFlag == 3) //move ChaosBox -> Inv
{
if (!lpObj->ChaosBox[aRecv->Source].IsItem())
return; //no item
this->ItemByteConvert(pMsg.ItemInfo, lpObj->ChaosBox[aRecv->Source]);

int Target = this->InventoryCheckInsertItem(aIndex, lpObj->ChaosBox[aRecv->Source].m_Index);

if (Target == 0xFF)
{
return;
}

pMsg.TargetSlot = Target;
}
else if (aRecv->tFlag == 0 & aRecv->sFlag == 0) //equip/unequip item
{
if (!lpObj->Inventory[aRecv->Source].IsItem())
return;
this->ItemByteConvert(pMsg.ItemInfo, lpObj->Inventory[aRecv->Source]);

if (aRecv->Source > 11) { //wear equipment case
ITEM_INFO ItemInfo;
if (this->GetInfo(lpObj->Inventory[aRecv->Source].m_Index, &ItemInfo) == 0)
{
return; //invalid item.
}
pMsg.TargetSlot = ItemInfo.Slot;
if (pMsg.TargetSlot == 0
&& lpObj->Inventory[0].IsItem() //slot 0 already has item
&& !lpObj->Inventory[1].IsItem() //slot 1 is empty
&& lpObj->Inventory[aRecv->Source].m_Index < GET_ITEM(1, 0)) //sword item
pMsg.TargetSlot = 1;
else if (lpObj->Inventory[ItemInfo.Slot].IsItem())
return; //already has item this slot
}
else { //unequipment case
int Target = this->InventoryCheckInsertItem(aIndex, lpObj->Inventory[aRecv->Source].m_Index);

if (Target == 0xFF)
{
return;
}

pMsg.TargetSlot = Target;
}
}
else {
return; //invalid case
}

pMsg.SourceFlag = aRecv->sFlag;
pMsg.TargetFlag = aRecv->tFlag;
pMsg.SourceSlot = aRecv->Source;


this->CGItemMoveRecv(&pMsg, aIndex);

if (aRecv->tFlag == 0 & aRecv->sFlag == 3){
gChaosBox.GCChaosBoxSend(lpObj, 0);

//update chaosBox by new packet????
PMSG_SET_CHAOSBOX_STATE pMsg = { 0 };

pMsg.header.set(0xF3, 0xEE, sizeof(pMsg));

pMsg.state = 0; //0 = allow mix || 2 = disable mix

DataSend(aIndex, (LPBYTE)&pMsg, pMsg.header.size);
}
else if ((aRecv->tFlag == 3 & aRecv->sFlag == 0) || (aRecv->tFlag == 0 & aRecv->sFlag == 0))
{
if (!lpObj->Inventory[aRecv->Source].IsItem()) {
this->GCItemDeleteSend(aIndex, aRecv->Source, aRecv->sFlag);
}
}


return;
}
#endif

ItemManager.h

#if(MOVE_ITEM)

struct PMSG_MOVEITEM {
PSBMSG_HEAD h;
BYTE sFlag;
BYTE tFlag;
BYTE Source;
BYTE Target;
};

struct PMSG_SET_CHAOSBOX_STATE
{
PSBMSG_HEAD header; // C1:32
BYTE state;
};

#endif


#if(MOVE_ITEM)
void CGMoveItemProc(PMSG_MOVEITEM* aRecv, short aIndex);
BYTE InventoryCheckInsertItem(int aIndex, WORD item);
#endif

Protocol.cpp

#if(MOVE_ITEM)
case 0x79:
switch (lpMsg[3])
{
case 0x01:
gItemManager.CGMoveItemProc((PMSG_MOVEITEM*)lpMsg, aIndex);
break;
}
break;
#endif

User.h

#if(MOVE_ITEM)
#define OBJMAX_RANGE(aIndex) (((aIndex) < 0 )?FALSE:( (aIndex) > MAX_OBJECT-1 )?FALSE:TRUE)
#endif

Créditos:
Thành Văn

alefmfoda
29/05/2020, 07:20 PM
Alguém tem tutoriais pra colocar nisso na sounce?

GangoX
20/09/2020, 12:18 AM
Funciona no season 4

ailsoncost
29/09/2020, 10:15 PM
Boa noite, arrumando gameserver com sucesso e main 1 failed então algum me ajuda

[Only registered and activated users can see links]

1>c:\users\applayo\downloads\muonlines\applayo games\[ex614] source\main_ex614\main\Protocol.h(647): fatal error C1004: unexpected end-of-file found

louis
30/09/2020, 04:36 PM
Boa noite, arrumando gameserver com sucesso e main 1 failed então algum me ajuda

[Only registered and activated users can see links]

1>c:\users\applayo\downloads\muonlines\applayo games\[ex614] source\main_ex614\main\Protocol.h(647): fatal error C1004: unexpected end-of-file found

muda isso:
#if(MOVE_ITEM)
struct PMSG_ITEM_MOVE_RECV
{
PSBMSG_HEAD h;
BYTE sFlag;
BYTE tFlag;
BYTE Source;
BYTE Target;
};

#if(MOVE_ITEM)
void SetChaosBoxState(PMSG_SET_CHAOSBOX_STATE* Data);
#endif

para isso:



struct PMSG_ITEM_MOVE_RECV
{
PSBMSG_HEAD h;
BYTE sFlag;
BYTE tFlag;
BYTE Source;
BYTE Target;
};


void SetChaosBoxState(PMSG_SET_CHAOSBOX_STATE* Data);

ailsoncost
30/09/2020, 10:29 PM
[Only registered and activated users can see links]

[Only registered and activated users can see links]


to sozinho tentei conesgui resolvido!

Gta1100
06/02/2021, 03:29 PM
[Only registered and activated users can see links]

Alguém me ajuda , gameserver deu certo , agora no main ta dando ruim

Mentor
06/02/2021, 05:35 PM
Tem de incluir o post_item.h

Gta1100
06/02/2021, 07:43 PM
[Only registered and activated users can see links]

mesma coisa mano ... ja coloquei

#include ([Only registered and activated users can see links]) "post_item.h"