Jump to content

[C++] Item delete packet


Guest Ezrekith

Recommended Posts

Hi folks!

 

Client source:

//ClientSide - Userinterface/Packet.h

//Add this after the includes if you don't have:

#include "Locale_inc.h"

//Search for:

HEADER_CG_ITEM_DROP2                        = 20,

//Add under:

#ifdef ENABLE_REMOVE_PACKET
HEADER_CG_ITEM_DESTROY                        = 21,
#endif

//Search for:

} TPacketCGItemDrop2;

//Add under:

#ifdef ENABLE_REMOVE_PACKET
typedef struct command_item_destroy
{
    BYTE        header;
    TItemPos    pos;
} TPacketCGItemDestroy;
#endif

//ClientSide - Userinterface/PythonNetworkStreamPhaseGameItem.cpp

//Add this after the includes if you don't have:

#include "Locale_inc.h"

//Search for:

bool CPythonNetworkStream::SendItemDropPacketNew(TItemPos pos, DWORD elk, DWORD count)

//After the definition of SendItemDropPacketNew add under:

#ifdef ENABLE_REMOVE_PACKET
bool CPythonNetworkStream::SendItemDestroyPacket(TItemPos pos)
{
    if (!__CanActMainInstance())
        return true;
    TPacketCGItemDestroy itemDestroyPacket;
    itemDestroyPacket.header = HEADER_CG_ITEM_DESTROY;
    itemDestroyPacket.pos = pos;
    if (!Send(sizeof(itemDestroyPacket), &itemDestroyPacket))
    {
        Tracen("SendItemDestroyPacket Error");
        return false;
    }
    return SendSequence();
}
#endif

//ClientSide - Userinterface/PythonNetworkStreamModule.cpp

//Add this after the includes if you don't have:

#include "Locale_inc.h"

//Search for:

PyObject* netSendItemDropPacket(PyObject* poSelf, PyObject* poArgs)

//After the definition of netSendItemDropPacket add under:

#ifdef ENABLE_REMOVE_PACKET
PyObject* netSendItemDestroyPacket(PyObject* poSelf, PyObject* poArgs)
{
    TItemPos Cell;
    
    if (!PyTuple_GetInteger(poArgs, 0, &Cell.cell))
        return Py_BuildException();
    CPythonNetworkStream& rkNetStream = CPythonNetworkStream::Instance();
    rkNetStream.SendItemDestroyPacket(Cell);
    return Py_BuildNone();
}
#endif

//Search for this:

{ "SendItemDropPacketNew",                netSendItemDropPacketNew,                METH_VARARGS },

//Add under:

#ifdef ENABLE_REMOVE_PACKET
{ "SendItemDestroyPacket",                netSendItemDestroyPacket,                METH_VARARGS },
#endif

//ClientSide - Userinterface/PythonNetworkStream.h

//Add this after the includes if you don't have:

#include "Locale_inc.h"

//Search for:

bool SendItemDropPacketNew(TItemPos pos, DWORD elk, DWORD count);

//Add under:

#ifdef ENABLE_REMOVE_PACKET
bool SendItemDestroyPacket(TItemPos pos);
#endif

//ClientSide - Userinterface/PythonApplicationModule.cpp

//Add this after the includes if you don't have:

#include "Locale_inc.h"

//Search for:

PyModule_AddIntConstant(poModule, "CAMERA_STOP",			CPythonApplication::CAMERA_STOP);

//Add under:

#ifdef ENABLE_REMOVE_PACKET
	PyModule_AddIntConstant(poModule, "DELETE_ITEM_PACKET", 1);
#else
	PyModule_AddIntConstant(poModule, "DELETE_ITEM_PACKET", 0);
#endif

//ClientSide - Userinterface/Locale_inc.h
//Add this:

#define ENABLE_REMOVE_PACKET

Server source:

//Serverside - game/Packet.h

//Add this after the includes if you don't have:

#include "../../common/service.h"

//Search for:

HEADER_CG_ITEM_DROP2            = 20,

//Add under:

#ifdef ENABLE_REMOVE_PACKET
HEADER_CG_ITEM_DESTROY            = 21,
#endif

//Search for:

} TPacketCGItemDrop2;

//Add Under:

#ifdef ENABLE_REMOVE_PACKET
typedef struct command_item_destroy
{
    BYTE        header;
    TItemPos    Cell;
} TPacketCGItemDestroy;
#endif

//Serverside - game/Packet_info.cpp

//Add this after the includes if you don't have:

#include "../../common/service.h"

//Search for:

Set(HEADER_CG_ITEM_DROP2, sizeof(TPacketCGItemDrop2), "ItemDrop2", true);

//Add under:

#ifdef ENABLE_REMOVE_PACKET
Set(HEADER_CG_ITEM_DESTROY, sizeof(TPacketCGItemDestroy), "ItemDestroy", true);
#endif

//Serverside - game/Input_main.cpp

//Add this after the includes if you don't have:

#include "../../common/service.h"

//Search for:

void CInputMain::ItemDrop2(LPCHARACTER ch, const char * data)

//After the definition of ItemDrop2 add this:

#ifdef ENABLE_REMOVE_PACKET
void CInputMain::ItemDestroy(LPCHARACTER ch, const char * data)
{
    struct command_item_destroy * pinfo = (struct command_item_destroy *) data;
    if (ch)
        ch->DestroyItem(pinfo->Cell);
}
#endif

//Search for:

case HEADER_CG_ITEM_DROP2:

//Add under:

#ifdef ENABLE_REMOVE_PACKET
        case HEADER_CG_ITEM_DESTROY:
            if (!ch->IsObserverMode())
                ItemDestroy(ch, c_pData);
        break;
#endif

//Serverside - game/Char.cpp

//Add this after the includes if you don't have:

#include "../../common/service.h"

//Search for:

bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)

//After the definition of DropItem add this:

#ifdef ENABLE_REMOVE_PACKET
bool CHARACTER::DestroyItem(TItemPos Cell)
{
    LPITEM item = NULL;
    if (!CanHandleItem())
    {
        if (NULL != DragonSoul_RefineWindow_GetOpener())
            ChatPacket(CHAT_TYPE_INFO, LC_TEXT("°*E*AcA» ?¬ »óAÂ?!1*´Â 3AAIAUA» ?A±a 1ö 3o1A´I´U."));
        return false;
    }
    if (IsDead())
        return false;
    if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
        return false;
    if (item->IsExchanging())
        return false;
    if (true == item->isLocked())
        return false;
    if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
        return false;
    if (item->GetCount() <= 0)
        return false;
    SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255);
    ITEM_MANAGER::instance().RemoveItem(item);
    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Du hast %s zerstoert."), item->GetName());
    return true;
}
#endif

//Serverside - game/Char.h

//Add this after the includes if you don't have:

#include "../../common/service.h"

//Search for:

bool            DropItem(TItemPos Cell,  BYTE bCount=0);

//Add Under:

#ifdef ENABLE_REMOVE_PACKET
bool            DestroyItem(TItemPos Cell);
#endif

//Serverside - game/Input.h

//Add this after the includes if you don't have:

#include "../../common/service.h"

//Search for:

void        ItemDrop2(LPCHARACTER ch, const char * data);

//Add Under:

#ifdef ENABLE_REMOVE_PACKET
void        ItemDestroy(LPCHARACTER ch, const char * data);
#endif

//Serverside - common/service.h

//Add this:

#define ENABLE_REMOVE_PACKET

Python:

#root/uiCommon.py

#Search for:

class QuestionDialog(ui.ScriptWindow):

#Add this above:

if app.DELETE_ITEM_PACKET:
	class QuestionDialogItem(ui.ScriptWindow):
	
		def __init__(self):
			ui.ScriptWindow.__init__(self)
			self.__CreateDialog()
			
		def __del__(self):
			ui.ScriptWindow.__del__(self)
			
		def __CreateDialog(self):
			pyScrLoader = ui.PythonScriptLoader()
			pyScrLoader.LoadScriptFile(self, "uiscript/newquestiondialogitem.py")
			self.board = self.GetChild("board")
			self.textLine = self.GetChild("message")
			self.acceptButton = self.GetChild("accept")
			self.destroyButton = self.GetChild("destroy")
			self.cancelButton = self.GetChild("cancel")
			
		def Open(self):
			self.SetCenterPosition()
			self.SetTop()
			self.Show()
			
		def Close(self):
			self.Hide()
			
		def SetWidth(self, width):
			height = self.GetHeight()
			self.SetSize(width, height)
			self.board.SetSize(width, height)
			self.SetCenterPosition()
			self.UpdateRect()
			
		def SAFE_SetAcceptEvent(self, event):
			self.acceptButton.SAFE_SetEvent(event)
			
		def SAFE_SetCancelEvent(self, event):
			self.cancelButton.SAFE_SetEvent(event)
			
		def SetAcceptEvent(self, event):
			self.acceptButton.SetEvent(event)

		def SetDestroyEvent(self, event):
			self.destroyButton.SetEvent(event)
			
		def SetCancelEvent(self, event):
			self.cancelButton.SetEvent(event)
			
		def SetText(self, text):
			self.textLine.SetText(text)
			
		def SetAcceptText(self, text):
			self.acceptButton.SetText(text)
			

			
		def SetCancelText(self, text):
			self.cancelButton.SetText(text)
			
		def OnPressEscapeKey(self):
			self.Close()
			return TRUE
		
#root/game.py

#Search for this:

def __DropItem(self, attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount):

#After that Search for this:

				itemDropQuestionDialog = uiCommon.QuestionDialog()

#Replace with:

				if app.DELETE_ITEM_PACKET:
					itemDropQuestionDialog = uiCommon.QuestionDialogItem()
				else:
					itemDropQuestionDialog = uiCommon.QuestionDialog()

#Search for this:

				itemDropQuestionDialog.SetAcceptEvent(lambda arg=TRUE: self.RequestDropItem(arg))

#Add under:

				if app.DELETE_ITEM_PACKET:
					itemDropQuestionDialog.SetDestroyEvent(lambda arg=TRUE: self.RequestDestroyItem(arg))

#Search for this:

def RequestDropItem(self, answer):

#After the definition of RequestDropItem add under:

	if app.DELETE_ITEM_PACKET:
		def RequestDestroyItem(self, answer):
			if not self.itemDropQuestionDialog:
				return
				
			if answer:
				dropType = self.itemDropQuestionDialog.dropType
				dropNumber = self.itemDropQuestionDialog.dropNumber
				if player.SLOT_TYPE_INVENTORY == dropType:
					if dropNumber == player.ITEM_MONEY:
						return
					else:
						self.__SendDestroyItemPacket(dropNumber)
		
			self.itemDropQuestionDialog.Close()
			self.itemDropQuestionDialog = None
			constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)

#Search for:

def __SendDropItemPacket(self, itemVNum, itemCount, itemInvenType = player.INVENTORY):

#After the definition of __SendDropItemPacket add under:

	if app.DELETE_ITEM_PACKET:
		def __SendDestroyItemPacket(self, itemVNum, itemInvenType = player.INVENTORY):
			if uiPrivateShopBuilder.IsBuildingPrivateShop():
				chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
				return
			net.SendItemDestroyPacket(itemVNum)
		
		
#locale/ui/locale_interface.txt
#Add this:
DESTROY    Destroy

uiscript.rar

Edited by Ezrekith
Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...
  • 2 weeks later...
  • 6 months later...
  • 3 months later...

Alguém que tenha conseguido? 

Possuo erro no game.py...

 

Syserr:

0301 01:54:16164 :: Traceback (most recent call last):

0301 01:54:16164 ::   File "networkModule.py", line 237, in SetGamePhase

0301 01:54:16164 ::   File "system.py", line 177, in __hybrid_import

0301 01:54:16164 ::   File "
0301 01:54:16164 :: game.py
0301 01:54:16164 :: ", line 
0301 01:54:16164 :: 1444
0301 01:54:16164 :: 

0301 01:54:16164 ::     
0301 01:54:16164 :: if app.DELETE_ITEM_PACKET:

0301 01:54:16164 :: IndentationError
0301 01:54:16164 :: : 
0301 01:54:16164 :: unindent does not match any outer indentation level

Edited by nãoéstu
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
  • 3 months later...
  • 5 weeks later...
  • 4 weeks later...
  • 3 weeks later...
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...