gto32132 發表於 2016-8-3 11:21

在遊戲增加另一種貨幣

代瑪如下:
首先在SHOP表裏添加一個欄目“yuanbao”,這個是物品賣出的價錢。
1,找到SHOPTABLE.JAVA
查找private L1Shop loadShop(int npcId, ResultSet rs) throws SQLException {
改成和下面一樣
private L1Shop loadShop(int npcId, ResultSet rs) throws SQLException {
List<L1ShopItem> sellingList = new ArrayList<L1ShopItem>();
List<L1ShopItem> purchasingList = new ArrayList<L1ShopItem>();
while (rs.next()) {
int itemId = rs.getInt("item_id");
int sellingPrice = rs.getInt("selling_price");
int purchasingPrice = rs.getInt("purchasing_price");
int packCount = rs.getInt("pack_count");
packCount = packCount == 0 ? 1 : packCount;
                        int yuanbao = rs.getInt("yuanbao");//add liumy
    &%INfl>o7.
switch(npcId){
case 70068:case 70020:
case 70024:case 70032:
case 80075:
    continue;
default:
    break;
}
   
if(0 <= sellingPrice){
    if(_allItemSells.get(itemId)==null){
    _allItemSells.put(itemId, sellingPrice/2);
    }else if(_allItemSells.get(itemId)<sellingPrice/2){
    _allItemSells.put(itemId, sellingPrice/2);
    }
}else{//-1
    if(0 <= purchasingPrice){
    if(_allItemSells.get(itemId)==null){
      _allItemSells.put(itemId, purchasingPrice);
    }else if(_allItemSells.get(itemId)<purchasingPrice){
      _allItemSells.put(itemId, purchasingPrice);
    }
    }
}
   
if (0 <= sellingPrice && 0 >= yuanbao) {
    L1ShopItem item = new L1ShopItem(itemId, sellingPrice,
      packCount);
    sellingList.add(item);
}
if (0 <= purchasingPrice && 0 >= yuanbao) {
    L1ShopItem item = new L1ShopItem(itemId, purchasingPrice,
      packCount);
    purchasingList.add(item);
}
if (0 < yuanbao) {//add liumy
    L1ShopItem item = new L1ShopItem(itemId, yuanbao,
      packCount);
    sellingList.add(item);
}//add liumy end
}
return new L1Shop(npcId, sellingList, purchasingList);
}


2,打開SHOP.JAVA
查找 private boolean ensureSell(L1PcInstance pc, L1ShopBuyOrderList orderList) {
改成和下面一樣
private boolean ensureSell(L1PcInstance pc, L1ShopBuyOrderList orderList) {
int price = orderList.getTotalPriceTaxIncluded();
// オーバーフローチェック
if (!IntRange.includes(price, 0, 2000000000)) {
// 總販賣価格は%dアデナを超過できません。
pc.sendPackets(new S_ServerMessage(904, "2000000000"));
return false;
}
// 購入できるかチェック
//add liumy
int bb;
if (_npcId >= 990000 && _npcId <= 995000) {      //元寶商城專用NPC的ID
bb =61019;//元寶
}else{
bb =L1ItemId.ADENA;
}//add liumy
if (!pc.getInventory().checkItem(bb, price)) {
//l1j.eric.gui.J_Main.getInstance().addConsolPost(""+price);
// \f1アデナが不足しています。
if (L1ItemId.ADENA == bb){      //add liumy
pc.sendPackets(new S_ServerMessage(189));
}else{
    pc.sendPackets(new S_SystemMessage("元寶不足"));//add liumy
    //pc.sendPackets(new S_ServerMessage(189));
}
return false;
}
// 重量チェック
int currentWeight = pc.getInventory().getWeight() * 1000;
if (currentWeight + orderList.getTotalWeight() > pc.getMaxWeight() * 1000) {
再找到 private void sellItems(L1PcInventory inv, L1ShopBuyOrderList orderList) {
改成
private void sellItems(L1PcInventory inv, L1ShopBuyOrderList orderList) {
//add liumy
int bb;
if (_npcId >= 990000 && _npcId <= 995000) {
bb =61019; //元寶 BqZLqGO Ku
}else{
bb =L1ItemId.ADENA;
}
if (!inv.consumeItem(bb, orderList
    .getTotalPriceTaxIncluded())) {
throw new IllegalStateException("購入に必要なアデナを消費できませんでした。");
}
for (L1ShopBuyOrder order : orderList.getList()) {
改這二個文件,元寶商城就可以了,隻是窗口顯示是金币的數量,如果不想顯示的話。
修改二個文件,(s_scrollshopselllist.java和S_shopselllist.java)
找到,writeH(0x07); // 0x00:kaimo 0x01:pearl 0x07:adena
修改成
if (npcId >= 990000 && npcId <= 995000){
writeH(0x0C8C); // 0x00:kaimo 0x01:pearl 0x07:adena    //如果誰知道官方天寶的封包是多少就好了,我隻好亂寫個0x0C8C
      }else{
      writeH(0x07); // 0x00:kaimo 0x01:pearl 0x07:adena
          }
END


回覆是我發帖的動力~!

kuku77881 發表於 2016-8-3 19:26

感謝大大無私分享.................................

qoo99281 發表於 2016-8-4 17:23

再實驗看看感謝;P

asd741028 發表於 2017-6-26 22:23

等等新增一下看看

pp12364 發表於 2017-7-8 17:03

多謝分享趕緊來試試~~~~

gygy938 發表於 2017-7-12 16:05

謝謝大大的分享^^

pp720101 發表於 2017-7-21 18:16

目前學習中,謝謝分享。

aaaalkj520 發表於 2017-8-23 18:59

感謝大大無私分享 先收下了

jjen0206 發表於 2018-2-24 06:32

感謝大大分享

好學生 發表於 2018-2-24 10:49

發帖是我回帖的動力~!

puenhan 發表於 2018-3-13 11:48

大哥您這個 是對應到哪一個版本

minjung 發表於 2018-5-17 15:54

thanks@@@@!!@!@!

小巴 發表於 2021-4-19 10:37

感謝大大的分享!非常有用

bennyst 發表於 2021-7-23 00:13

test1234 發表於 2021-7-23 00:19

感謝版大的經驗分享,推

moc081388 發表於 2021-8-3 12:04

       
感謝分享唷

hui52888 發表於 2021-8-22 15:02

多謝分享 實驗中

gz1991001 發表於 2021-8-23 05:39

感謝大大無私分享

kobe61501 發表於 2021-10-22 22:01

沒有基礎完全看不懂QQ.

asd07050116 發表於 2021-12-27 00:58

樓主大哥可以分享一下怎麼弄的嗎,謝謝樓主大哥~
頁: [1] 2 3
查看完整版本: 在遊戲增加另一種貨幣