[SRC]Destroy slot/Tárgy törlő

Indította 5310pati, 2018-03-15, 16:05:41

2018-03-15, 16:05:41 Utolsó szerkesztés: 2018-03-16, 18:22:20 Szerző: 5310pati
Szerver
packet.h
HEADER_CG_ITEM_DROP2 = 20,
alá:
HEADER_CG_ITEM_DESTROY = 21,
majd
} TPacketCGItemDrop2;
alá:
typedef struct command_item_destroy
{
BYTE header;
TItemPos Cell;
} TPacketCGItemDestroy;



packet_info.cpp
Set(HEADER_CG_ITEM_DROP2, sizeof(TPacketCGItemDrop2), "ItemDrop2", true);
alá:
Set(HEADER_CG_ITEM_DESTROY, sizeof(TPacketCGItemDestroy), "ItemDestroy", true);


input_main.cpp
void CInputMain::ItemMove(LPCHARACTER ch, const char * data)
fölé:
void CInputMain::ItemDestroy(LPCHARACTER ch, const char * data)
{
TPacketCGItemDestroy * pinfo = (TPacketCGItemDestroy *)data;

if (!ch)
return;
if (pinfo->Cell.cell < 0 || pinfo->Cell.cell > INVENTORY_MAX_NUM)
return;
else
ch->DestroyItem(pinfo->Cell);
}

majd
case HEADER_CG_ITEM_MOVE:
fölé:
case HEADER_CG_ITEM_DESTROY:
if (!ch->IsObserverMode())
ItemDestroy(ch, c_pData);
break;


input.h
void ItemDrop2(LPCHARACTER ch, const char * data);
alá:
void ItemDestroy(LPCHARACTER ch, const char * data);


char.h
bool DropItem(TItemPos Cell,  WORD bCount=0);
alá:
bool DestroyItem(TItemPos Cell);


char_item.cpp
bool CHARACTER::DropGold(long long gold)
fölé:
bool CHARACTER::DestroyItem(TItemPos Cell)
{
LPITEM item = NULL;
if (!CanHandleItem())
{
return false;
}
if (IsDead())
return false;
if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
return false;
if (item->IsExchanging())
return false;
if (item->IsEquipped())
{
ChatPacket(CHAT_TYPE_INFO, "Felszerelt tárgyat nem semmisíthetsz meg!");
return false;
}
if (true == item->isLocked())
return false;
if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
return false;
if (item->GetCount() <= 0)
return false;
ITEM_MANAGER::instance().RemoveItem(item);
SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 1000);
ChatPacket(CHAT_TYPE_INFO, "%ddb %s megsemmisítve.", item->GetCount(), item->GetName());
return true;
}



Indító
packet.h
HEADER_CG_ITEM_DROP2 = 20,
alá:
HEADER_CG_ITEM_DESTROY = 21,
majd
typedef struct command_item_move
fölé:
typedef struct command_item_destroy
{
BYTE header;
TItemPos Cell;
} TPacketCGItemDestroy;



PythonNetworkStreamModule.cpp
PyObject* netSendItemMovePacket(PyObject* poSelf, PyObject* poArgs)
fölé:
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();
}

majd
{ "SendGoldDropPacketNew", netSendGoldDropPacketNew, METH_VARARGS },
alá:
{ "SendItemDestroyPacket", netSendItemDestroyPacket, METH_VARARGS },


PythonNetworkStream.h
bool SendItemDropPacketNew(TItemPos pos, DWORD elk, DWORD count);
alá:
bool SendItemDestroyPacket(TItemPos pos);


PythonNetworkStreamPhaseGameItem.cpp
bool CPythonNetworkStream::__IsEquipItemInSlot(TItemPos uSlotPos)
fölé:
bool CPythonNetworkStream::SendItemDestroyPacket(TItemPos pos)
{
if (!__CanActMainInstance())
return true;

TPacketCGItemDestroy itemDestroyPacket;
itemDestroyPacket.header = HEADER_CG_ITEM_DESTROY;
itemDestroyPacket.Cell = pos;

if (!Send(sizeof(itemDestroyPacket), &itemDestroyPacket))
{
Tracen("SendItemDestroyPacket Error");
return false;
}

return SendSequence();
}



Python
locale/inventorywindow.py
## MallButton
fölé:
## DestroySlot
{
"name" : "DestroySlotImg",
"type" : "image",

"image" : "D:/ymir work/ui/game/destroy_slot.dds",

"x" : 200,
"y" : 148,

"children" :
(
{
"name" : "DestroySlot",
"type" : "slot",

"x" : 1,
"y" : 1,

"width" : 32,
"height" : 32,

"slot" : (
{"index":1, "x":0, "y":0, "width":30, "height":30},
),
},
),
},

képet,pozíciót ezzel állítjátok:
"image" : "D:/ymir work/ui/game/destroy_slot.dds",

"x" : 200,
"y" : 148,


root/uiinventory.py
self.mallButton = self.GetChild2("MallButton")
alá:
self.destroySlot = self.GetChild2("DestroySlot")
majd
if self.mallButton:
self.mallButton.SetEvent(ui.__mem_func__(self.ClickMallButton))

alá:
if self.destroySlot:
self.destroySlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.DestroyItemDialog))

TABOLÁSRA FIGYELNI!!!
majd
def Destroy(self):
fölé:
def DestroyItemDialog(self):
if mouseModule.mouseController.isAttached():
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()

item.SelectItem("uiinventory", int(attachedItemIndex))
dstitemName = item.GetItemName()

self.questionDialog = uiCommon.QuestionDialog()
self.questionDialog.SetText(localeInfo.DO_YOU_DESTROY_ITEM(attachedItemCount, dstitemName))
self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.DestroyItem))
self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
self.questionDialog.Open()
self.questionDialog.pos = attachedSlotPos

mouseModule.mouseController.DeattachObject()

def DestroyItem(self):
dstry_pos = self.questionDialog.pos
net.SendItemDestroyPacket(dstry_pos)
snd.PlaySound("sound/ui/jaeryun_fail.wav")
self.OnCloseQuestionDialog()


root/locale v localeinfo.py
másold be
def DO_YOU_DESTROY_ITEM(count, name):
return DO_YOU_DESTROY_ITEM1 % (count, name)


locale/locale_game.txt
másold be
DO_YOU_DESTROY_ITEM1 Biztos meg akarsz semmisíteni %sdb %s-t?




Végeredmény meg vmi ilyesmi lesz: