Guida Transferire Bonus Costumi

hathormetin

Utente Bronze
5 Luglio 2018
12
2
3
23
Il Transfer bonus costume si limita a trasferire i bonus da un costume ad un altro indipendentemente se maschile o femmile.

Apri game/char.h

Aggiungi:
void CostumeBonusTransfer(DWORD cell1, DWORD cell2);

Apri game/char.cpp

Aggiungi:
void CHARACTER::CostumeBonusTransfer(DWORD cell1, DWORD cell2)
{
int CostumeTransferBonusItemVnum = 76025; // costume bonus transfer item vnum
if ((GetExchange() || IsOpenSafebox() || GetShopOwner()) || IsCubeOpen() || IsDead())
{
ChatPacket(CHAT_TYPE_INFO, "Attenzione: uno dei due costumi verrà distrutto!");
return;
}

LPITEM costume1 = GetInventoryItem(cell1);
LPITEM costume2 = GetInventoryItem(cell2);
if (!costume1){
ChatPacket(CHAT_TYPE_INFO, "Il costume non è stato trovato!");
return;
}

if (costume1->GetType() != ITEM_COSTUME || costume1->GetType() == ITEM_COSTUME && costume1->GetSubType() != ARMOR_BODY)
{
ChatPacket(CHAT_TYPE_INFO, "Questo può essere fatto solo con costumi !");
return;
}

if (!costume2){
ChatPacket(CHAT_TYPE_INFO, "Il costume non è stato trovato!");
return;
}

if (costume2->GetType() != ITEM_COSTUME || costume2->GetType() == ITEM_COSTUME && costume2->GetSubType() != ARMOR_BODY)
{
ChatPacket(CHAT_TYPE_INFO, "Solo i bonus dei costumi possono essere trasferiti!");
return;
}

if (CountSpecifyItem(CostumeTransferBonusItemVnum) < 1){
ChatPacket(CHAT_TYPE_INFO, "Elementi essenziali del trasferimento bonus non trovati");
return;
}

if (costume2->GetAttributeCount() < 1){
ChatPacket(CHAT_TYPE_INFO, "Un costume senza bonus non può essere trasferito!");
return;
}


RemoveSpecifyItem(CostumeTransferBonusItemVnum, 1);
costume1->ClearAttribute();
for (int i = 0; i < costume2->GetAttributeCount(); i++){
costume1->SetForceAttribute(i, costume2->GetAttributeType(i), costume2->GetAttributeValue(i));
}

costume2->RemoveFromCharacter();

ChatPacket(CHAT_TYPE_INFO, "Trasferimento bonus costume riuscito!");
}

Apri cmd.cpp

Cercai:
ACMD(do_block_chat);

Aggiungi:

ACMD(do_costume_bonus_transfer);

Apri cmd_gm.cpp

Cerca:
ACMD(do_block_chat)
{
// GM이 아니거나 block_chat_privilege가 없는 사람은 명령어 사용 불가
if (ch && (ch->GetGMLevel() < GM_HIGH_WIZARD && ch->GetQuestFlag("chat_privilege.block") <= 0))
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("그런 명령어는 없습니다"));
return;
}

char arg1[256];
argument = one_argument(argument, arg1, sizeof(arg1));

if (!*arg1)
{
if (ch)
ch->ChatPacket(CHAT_TYPE_INFO, "Usage: block_chat <name> <time> (0 to off)");

return;
}

const char* name = arg1;
long lBlockDuration = parse_time_str(argument);

if (lBlockDuration < 0)
{
if (ch)
{
ch->ChatPacket(CHAT_TYPE_INFO, "잘못된 형식의 시간입니다. h, m, s를 붙여서 지정해 주십시오.");
ch->ChatPacket(CHAT_TYPE_INFO, "예) 10s, 10m, 1m 30s");
}
return;
}

sys_log(0, "BLOCK CHAT %s %d", name, lBlockDuration);

LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(name);

if (!tch)
{
CCI * pkCCI = P2P_MANAGER::instance().Find(name);

if (pkCCI)
{
TPacketGGBlockChat p;

p.bHeader = HEADER_GG_BLOCK_CHAT;
strlcpy(p.szName, name, sizeof(p.szName));
p.lBlockDuration = lBlockDuration;
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGBlockChat));
}
else
{
TPacketBlockChat p;

strlcpy(p.szName, name, sizeof(p.szName));
p.lDuration = lBlockDuration;
db_clientdesc->DBPacket(HEADER_GD_BLOCK_CHAT, ch ? ch->GetDesc()->GetHandle() : 0, &p, sizeof(p));
}

if (ch)
ch->ChatPacket(CHAT_TYPE_INFO, "Chat block requested.");

return;
}

if (tch && ch != tch)
tch->AddAffect(AFFECT_BLOCK_CHAT, POINT_NONE, 0, AFF_NONE, lBlockDuration, 0, true);
}

Aggiungi:
ACMD(do_costume_bonus_transfer)
{
char arg1[256], arg2[256];
DWORD cell1, cell2;
two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));

if (!*arg1 || !*arg2)
return;
str_to_number(cell1, arg1);
str_to_number(cell2, arg2);

if (cell1 < 0 || cell1 > INVENTORY_MAX_NUM || cell2 < 0 || cell2 > INVENTORY_MAX_NUM || cell1 == cell2)
return;

ch->CostumeBonusTransfer(cell1, cell2);
}

Aprite Root

create un file rinominato uibonustransfer.py ed aggiungeteci
import ui
import player
import event
import uiToolTip
import exception
import item
import uiCommon
import mouseModule
import chat
import net

class BonusTransfer(ui.ScriptWindow):

def __init__(self):
ui.ScriptWindow.__init__(self)
self.buttons, self.grids, self.costumes = {}, {}, {300 : {},303 : {},}
self.__Load()

self.tooltipItem = uiToolTip.ItemToolTip()
self.tooltipItem.Hide()

def __del__(self):
ui.ScriptWindow.__del__(self)
self.Close()

def __Load_LoadScript(self, fileName):
try:
pyScriptLoader = ui.PythonScriptLoader()
pyScriptLoader.LoadScriptFile(self, fileName)
except:
import exception
exception.Abort("BonusTransfer.__Load_LoadScript")

def __Load_BindObject(self):
try:
self.titleBar = self.GetChild("TitleBar")
self.grids[300] = self.GetChild("Costume1")
self.grids[303] = self.GetChild("Costume2")
self.grids[2] = self.GetChild("Costume3")
self.grids[3] = self.GetChild("Item")
self.buttons[0] = self.GetChild("Button1")
self.buttons[1] = self.GetChild("Button2")
except:
import exception
exception.Abort("BonusTransfer.__Load_BindObject")

self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.grids[300].SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.grids[300].SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.grids[300].SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
self.grids[300].SetUnselectItemSlotEvent(ui.__mem_func__(self.UnselectItemSlot))
self.grids[303].SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.grids[303].SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.grids[303].SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
self.grids[303].SetUnselectItemSlotEvent(ui.__mem_func__(self.UnselectItemSlot))
self.grids[2].SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.grids[2].SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.grids[3].SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.grids[3].SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.grids[3].SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
self.grids[3].SetUnselectItemSlotEvent(ui.__mem_func__(self.UnselectItemSlot))
self.buttons[0].SetEvent(self.TransferDialog)
self.buttons[1].SetEvent(self.Close)

def __Load(self):
self.__Load_LoadScript("uiscript/bonustransfer.py")
self.__Load_BindObject()

def OnPressEscapeKey(self):
self.Close()
return TRUE

def Shows(self):
ui.ScriptWindow.Show(self)

def Close(self):
self.Hide()
return TRUE

def TransferDialog(self):
self.ConfirmEkran = uiCommon.QuestionDialog()
self.ConfirmEkran.SetText("Kostüm bonusu aktarılsın mı ?")
self.ConfirmEkran.SetAcceptEvent(self.Transfer)
self.ConfirmEkran.SetCancelEvent(self.NoTransfer)
self.ConfirmEkran.Open()

def Transfer(self):
self.ConfirmEkran.Close()
if self.costumes[300][0] is None or self.costumes[303][0] is None:
return
self.grids[3].ClearSlot(3)
self.grids[3].RefreshSlot()
self.grids[303].ClearSlot(303)
self.grids[303].RefreshSlot()
net.SendChatPacket("/costume_bonus_transfer "+str(self.costumes[300][0])+" "+str(self.costumes[303][0]))
self.Close()

def NoTransfer(self):
self.ConfirmEkran.Close()

def OverInItem(self, index):
target = 303
if index == 400:
itemVnum = player.GetItemIndex(self.costumes[300][0])
if self.costumes[303][0] is None:
target = 300
stones = [player.GetItemMetinSocket(self.costumes[target][0], i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
attr = [player.GetItemAttribute(self.costumes[target][0], i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
self.tooltipItem.SetControledToolTip(itemVnum, stones, attr)
else:
if self.costumes[index] is None:
return
self.tooltipItem.SetInventoryItem(self.costumes[index][0])

def OverOutItem(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()

def SelectEmptySlot(self, selectedSlotPos):
if mouseModule.mouseController.isAttached():
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
itemVnum = player.GetItemIndex(attachedSlotPos)
itemCount = player.GetItemCount(attachedSlotPos)
item.SelectItem(itemVnum)
itemType = item.GetItemType()
itemSubType = item.GetItemSubType()
if selectedSlotPos == 301:
selectedSlotPos = 300
if selectedSlotPos == 304:
selectedSlotPos = 303
if selectedSlotPos == 403:
if itemVnum == 76025: # costume bonus transfer item kod
self.grids[3].SetItemSlot(403, itemVnum, itemCount)
else:
return
mouseModule.mouseController.DeattachObject()
if player.SLOT_TYPE_INVENTORY == attachedSlotType:
if itemType != item.ITEM_TYPE_COSTUME:
mouseModule.mouseController.DeattachObject()
return
elif itemType == item.ITEM_TYPE_COSTUME and itemSubType == 0:
pass
if attachedSlotPos in self.costumes:
mouseModule.mouseController.DeattachObject()
return
self.grids[selectedSlotPos].SetItemSlot(selectedSlotPos, itemVnum)
self.grids[selectedSlotPos].RefreshSlot()
self.costumes[selectedSlotPos][0] = attachedSlotPos
if selectedSlotPos == 300:
self.grids[2].SetItemSlot(400, itemVnum)

mouseModule.mouseController.DeattachObject()
self.OverOutItem()

def UnselectItemSlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isAttached()
if not isAttached:
self.costumes[selectedSlotPos][0] = 0
self.grids[selectedSlotPos].ClearSlot(selectedSlotPos)
self.grids[selectedSlotPos].RefreshSlot()
if selectedSlotPos == 300:
self.grids[2].ClearSlot(400)
self.grids[2].RefreshSlot()

Aprite game.py

Cercate:
"MyShopPriceList" : self.__PrivateShop_PriceList,

Aggiungete:
"kostumekran" : self.OpenBonusTransferWindow,

game.py a fine linea aggiungere:
def OpenBonusTransferWindow(self):
import uibonustransfer
self.BonusTransfers = uibonustransfer.BonusTransfer()
self.BonusTransfers.Show()

Aprite Uiscript e create un file all'interno rinominato bonustransfer.py

Aggiungete:
window = {
"name" : "Bonusessssssss",
"style" : ("movable", "float",),
"x":(SCREEN_WIDTH - 188+8+8) / 2,
"y":(SCREEN_HEIGHT - 335) / 2,
"width" : 188+8+8,
"height" : 335+42,

"children" :
(
{
"name" : "Board",
"type" : "board",
"style" : ("attach",),

"x" : 0,
"y" : 0,

"width" : 188+8+8,
"height" : 335+42,

"children" :
(
{
"name" : "TitleBar",
"type" : "titlebar",
"style" : ("attach",),
"x" : 8,
"y" : 8,
"width" : 188+8+8-16,
"color" : "gray",
"children" :
(
{
"name":"TitleName",
"type":"text",
"x":0,
"y":4,
"text" : "Bonus Transfer",
"horizontal_align":"center",
"text_horizontal_align":"center"
},
),
},
{
"name" : "Background",
"type" : "image",
"x" : 8,
"y" : 28,
"image" : "comb1.tga",
"children" :
(
{
"name" : "Costume1",
"type" : "grid_table",
"x" : 28,
"y" : 67,
"x_count" : 1,
"y_count" : 3,
"x_step" : 32,
"y_step" : 32,
"start_index" : 300,
},
{
"name" : "Costume2",
"type" : "grid_table",
"x" : 128,
"y" : 67,
"x_count" : 1,
"y_count" : 3,
"x_step" : 32,
"y_step" : 32,
"start_index" : 303,
},
{
"name" : "Costume3",
"type" : "grid_table",
"x" : 80,
"y" : 185,
"x_count" : 1,
"y_count" : 3,
"x_step" : 32,
"y_step" : 32,
"start_index" : 400,
},
{
"name" : "Item",
"type" : "grid_table",
"x" : 80,
"y" : 14,
"x_count" : 1,
"y_count" : 1,
"x_step" : 32,
"y_step" : 32,
"start_index" : 403,
},
),
},

{
"name" : "Button1",
"type" : "button",
"x" : 34,
"y" : 342,
"text" : "Aktar",
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
},
{
"name" : "Button2",
"type" : "button",
"x" : 34+70,
"y" : 342,
"text" : "İptal",
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
},
),
},
),
}

Adesso dirigetevi nella vostra cartella quest create un file ed inseriteci questo all'interno:
quest costumbonus begin
state start begin
when 20087.chat."Transferire Bonus" begin
cmdchat("kostumekran")
setskin(NOWINDOW)
end
end
end

In Uiscript aggiungete il seguente file

comb1.tga

https://mega.nz/#!XMwxTJpA!5O276Tye1DMiMaG9caIVkWp9m2U6Xr0skLjlJumW5cI