顯示具有 調整 標籤的文章。 顯示所有文章
顯示具有 調整 標籤的文章。 顯示所有文章

2014年7月28日 星期一

【Java教學】更改升級時的血量

首先先從核心路徑到

 l1j.server.server.utils 


CalcStat.java

搜尋到以下段落
粗體數字請對應到最下面的解釋

public static short calcStatHp(int charType, int baseMaxHp, byte baseCon, int originalHpup) {
        short randomhp = 0;
    1    if (baseCon > 15) {
            randomhp = (short) (baseCon - 15);
        }
    2    if (charType == 0) { // プリンス
            randomhp += (short) (11 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.PRINCE_MAX_HP) {
               randomhp = (short) (Config.PRINCE_MAX_HP - baseMaxHp);
            }
        } else if (charType == 1) { // ナイト
            randomhp += (short) (17 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.KNIGHT_MAX_HP) {
            randomhp = (short) (Config.KNIGHT_MAX_HP - baseMaxHp);
            }
        } else if (charType == 2) { // エルフ
            randomhp += (short) (10 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.ELF_MAX_HP) {
            randomhp = (short) (Config.ELF_MAX_HP - baseMaxHp);
            }
        } else if (charType == 3) { // ウィザード
            randomhp += (short) (7 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.WIZARD_MAX_HP) {
            randomhp = (short) (Config.WIZARD_MAX_HP - baseMaxHp);
            }
        } else if (charType == 4) { // ダークエルフ
            randomhp += (short) (10 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.DARKELF_MAX_HP) {
              randomhp = (short) (Config.DARKELF_MAX_HP - baseMaxHp);
            }
        } else if (charType == 5) { // ドラゴンナイト
            randomhp += (short) (13 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.DRAGONKNIGHT_MAX_HP) {
                randomhp = (short) (Config.DRAGONKNIGHT_MAX_HP - baseMaxHp);
            }
        } else if (charType == 6) { // イリュージョニスト
            randomhp += (short) (9 + rnd.nextInt(2)); // 初期値分追加

            if (baseMaxHp + randomhp > Config.ILLUSIONIST_MAX_HP) {
                randomhp = (short) (Config.ILLUSIONIST_MAX_HP - baseMaxHp);
            }
        }

    3    randomhp += originalHpup;

        if (randomhp < 0) {
            randomhp = 0;
        }
        return randomhp;
    }





升級血量主要是1+2+3

1 是指基本體力(baseCon)大於15時..會等於baseCon-15
  小於的話就直接是0

2 是指各職業的加成方面...0~6分別是.王.騎.妖.法.黑.龍.幻
  以王為例..第一段 randomhp += (short) (11 + rnd.nextInt(2)); 
    就是指11+體力影響的隨機機率加到1的部份(所以到這裡是1+2)
    再下面那段..就只是判定有沒有到達伺服器最大血量而已

3 randomhp += originalHpup...
    所謂的 originalHpup 就是指創人物時點的素質影響...創人物時看左邊那表格有寫
  所以到這邊就是1+2+3

要更改時方法很多...
更改1...就是以點體量影響為主
更改2...就是以各職業影響為主
更改3...就是以剛開始點的素質為主..還有無影響的直接加成....這邊也可以全部刪除


如果是要更改...我是建議更改1跟2..


更改1....就用else if去寫..隨便舉例...
            if (baseCon > 15 && baseCon <= 24) {
            randomhp = (short) (baseCon - 15);
        } else if(baseCon>=25) {
            randomhp = (short) (10);
}


這樣就是指基本體質大於15並在24以下的話...就是基本體質-15

如果基本體質在25以上的話...就是以10做計算(點超過25也不影響升級的血量)

更改2....在randomhp += (short) (11 + rnd.nextInt(2)); 
              中間的11可以作為職業的血量的差異
      如果是想跳固定值的話...後面就改成 (short) (11);  中間11可以自己隨便填數字 


以此邏輯魔量也相同作法


2014年7月18日 星期五

【程式教學】修改 Eclipse 字體大小及編輯區顏色

修改 Eclipse 字體大小及編輯區顏色

一般來說編寫程式許多人會使用 Eclipse 這個軟體。


然而,Eclipse 編輯的環境字體非常小(對我來說),我希望可以把他設定的大一些,

把這個方法提供給需要的人,


此外,Eclipse 也能自訂編輯區的高亮色彩,可以改成類似 Sublime Text 2 的介面,

在編輯程式碼的時候可以更加的得心應手。


修改編輯區字體大小

    1. Window > Preference

    2. 右側General > Appearance > Colors and Fonts

    3. 將 Basic 展開,看到「Text Font」和「Text Editor Block Selection Font」

    4. 按下 Edit ,隨自己喜好調整即可。

修改編輯區高亮色彩

    1. 先到 Eclipse Color Themes 網頁

    2. 在下方可以看到許多已經修改好的成品,選擇喜歡的下載

    3. 下載時選擇「eclipse preference (EPF)」格式

    4. 下載完後,開啟Eclipse,File > Import

    5. 看到第一個 General 把它展開,選擇裡面的Preference

    6. From preference file 按下右邊的Browse...,開啟剛剛下載好的檔案

    7. 按下 Finish,完成

修改好大概就會長成這樣:



善待自己的眼睛


編輯xml檔

2014年6月16日 星期一

【伺服器教學】伺服器LAG解決方式

如果常遇到下述的幾種狀況:
  1. 怪物不會掉東西
  2. 怪物不會動
  3. 人物不會回血回魔
  4. 放魔法沒反應
  5. 伺服器人數過多就會LAG
  6. 大量玩家湧入就會LAG



有以上情況的話
教導各位另一種比較進階的優化JAVJ方法

=========================================================

首先 先回想一下
  1. 自己是否改太多自改的東西在伺服器裡面呢?
  2. 自己是否在武器裝備上使用太多特效了?

如果是的話,那很有可能就是資料庫過於龐大
常常會導致 JAVA新增資料不完全,如出現上述的狀況
以下幾種方法 嘗試看看,或許可以改善你的伺服器LAG問題

第一
你的SQL Table是否太低呢?
正常如果是照教學文章下去安裝的SQL
沒有特別改過的話 會是Table會是8m~10m這之間
會造成伺服器出現上述問題,可能是因為新增資料不完全,導致伺服器沒有接收到。

玩家在執行的動作或是伺服器傳來的資料,沒新增完全就會出現上述的情況
可以選擇修改 sql 內的 my.ini 就是所謂的修改 Table

首先 先打開 Navicat for MySQL 找到 伺服器監控 尋找 tmp_table_size
找到tmp_table_size之後,先記下他的數值是多少

之後,到 Mysql資料夾 裡面找到 my.ini
並且,搜尋 tmp_table_size 
正常他的數值會是你剛剛記下的那個數值
沒有錯的話,就把他的數值改大一點,至於多大就要看你電腦本身的配備決定。

可以自己嘗試看看 50m 100m
接下來,至 工作管理員 裡面把 sql 強制關閉 再重新開啟一次,或是直接重新開機

之後,在回到Navicat for MySQL 找到伺服器監控 尋找 tmp_table_size 檢查看看數值有沒有改變了,如果有就代表成功 。

如果還是剛剛的數值 ,那就表示失敗 再重做一次吧 ,如何不重新開機啟動 Mysql

方法如下:
ctrl+alt+Delete 找到處理程序 之後按一下M 找到 Mysql 
把Mysql結束處理程序 就可以了,至於打開他的方法就是 左下方
開始→程式集→MySQL→MySQL Server 6.0→MySQL Server Instance Config Wizard
之後,就照當初安裝的方法下去用吧

差在說他要啟動的時候 密碼必須打三次

2014年2月1日 星期六

【Java教學】龍騎士 死騎 鎖鏈劍 一格攻擊

龍騎士 死騎 鎖鏈劍 一格攻擊
一格攻擊是參考(3.8TW S_SkillIconGFX)

L1PolyMorph.java

尋找

if ((pc.getTempCharGfx() == 6034) || (pc.getTempCharGfx() == 6035) || !isMatchCause(polyId, cause)) {
if (cantPolyMessage) {
  pc.sendPackets(new S_ServerMessage(181)); // \f1無法變成你指定的怪物。
} else {
  pc.sendPackets(new S_ServerMessage(79));
}
return; 
}

下面新增:

if (polyId == 6142 || polyId == 6147 || polyId == 6152 || polyId == 6157
|| polyId == 9205 || polyId == 9206 || polyId == 6775 || polyId == 6137
|| polyId == 3784 || polyId == 11232 || polyId == 11234 || polyId == 11236
|| polyId == 11375 || polyId == 11623 || polyId == 11631 || polyId == 11653
|| polyId == 11735 || polyId == 12229 || polyId == 12230 || polyId == 12231
|| polyId == 12232){
if (pc.getInventory().getTypeEquipped(1, 18) == 1) {
  pc.setCurrentWeapon(83);
                pc.sendPackets(new S_SkillIconGFX(polyId, true));
}
}

尋找並新增:

// 解除變身
public static void undoPoly(L1Character cha) {
           if (cha instanceof L1PcInstance) {
   L1PcInstance pc = (L1PcInstance) cha;
   int classId = pc.getClassId();
   
   if (pc.getInventory().getTypeEquipped(1, 18) == 1) {   // <---新增
    pc.setCurrentWeapon(24);                       // <---新增
   }                                                      // <---新增
   
   pc.setTempCharGfx(classId);
   if (!pc.isDead()) {  
    pc.sendPackets(new S_ChangeShape(pc.getId(), classId, pc.getCurrentWeapon()));
    pc.broadcastPacket(new S_ChangeShape(pc.getId(), classId, pc.getCurrentWeapon()));
   }
                        pc.sendPackets(new S_SkillIconGFX(classId, false));    // <---新增



L1EquipmentSlot.java

新增宣告:

import l1j.server.server.serverpackets.S_SkillIconGFX;

尋找
          weapon.startEquipmentTimer(_owner);

整句修改成:

         int polyId = _owner.getTempCharGfx();
  if (polyId == 6142 || polyId == 6147 || polyId == 6152 || polyId == 6157
     || polyId == 9205 || polyId == 9206 || polyId == 6775 || polyId == 6137
     || polyId == 3784 || polyId == 11232 || polyId == 11234 || polyId == 11236
     || polyId == 11375 || polyId == 11623 || polyId == 11631 || polyId == 11653
     || polyId == 11735 || polyId == 12229 || polyId == 12230 || polyId == 12231
     || polyId == 12232){
   if (weapon.getItem().getType1() == 24){
    _owner.setCurrentWeapon(83);
    _owner.sendPackets(new S_SkillIconGFX(polyId, true));
   }else {
       _owner.setCurrentWeapon(weapon.getItem().getType1());
   }
  }else {
      _owner.setCurrentWeapon(weapon.getItem().getType1());
  }
  weapon.startEquipmentTimer(_owner);     

尋找並新增:

         private void removeWeapon(L1ItemInstance weapon) {
  int itemId = weapon.getItem().getItemId();
  _owner.setWeapon(null);
  _owner.setCurrentWeapon(0);
  int polyId = _owner.getTempCharGfx();                    // <---新增
  _owner.sendPackets(new S_SkillIconGFX(polyId, false));   // <---新增


S_SkillIconGFX.java

新增:

        public S_SkillIconGFX(int i, boolean changeWeapon) {
  writeC(Opcodes.S_OPCODE_SKILLICONGFX);
  writeC(0xa0);
  if (changeWeapon == true) {
   writeC(1);
  }else{
   writeC(0);
  }
  writeH(0);
  writeC(2);
  writeH(i);
}


DB 部分:

polymorphs 

尋找

polyid == 6142 || polyid == 6147 || polyid == 6152 || polyid == 6157
|| polyid == 9205 || polyid == 9206 || polyid == 6775 || polyid == 6137
|| polyid == 3784 || polyid == 11232 || polyid == 11234 || polyid == 11236
|| polyid == 11375 || polyid == 11623 || polyid == 11631 || polyid == 11653
|| polyid == 11735 || polyid == 12229 || polyid == 12230 || polyid == 12231
|| polyid == 12232




weaponequip 

751

改成

1791




OVER
文章出處 浪漫物語網路社區

2013年6月8日 星期六

【Java教學】【★★★★★】GM指令調整玩家等級

新增一組程式碼檔案

新增l1j\server\server\command\executor\L1Levelid.java
新增以下程式碼



QUOTE:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package l1j.server.server.command.executor;

import java.util.StringTokenizer;
import java.util.logging.Logger;

import l1j.server.server.datatables.ExpTable;
import l1j.server.server.model.L1World;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_ServerMessage;
import l1j.server.server.serverpackets.S_SystemMessage;
import l1j.server.server.utils.IntRange;

public class L1Levelid implements L1CommandExecutor {
private static Logger _log = Logger.getLogger(L1Levelid.class.getName());

private L1Levelid() {
}

public static L1CommandExecutor getInstance() {
return new L1Levelid();
}

public void execute(L1PcInstance pc, String cmdName, String arg) {
try {
StringTokenizer tok = new StringTokenizer(arg);
String char_name = tok.nextToken();
int level = Integer.parseInt(tok.nextToken());

L1PcInstance target = L1World.getInstance().getPlayer(char_name);
if (target == null) {
pc.sendPackets(new S_ServerMessage(73, char_name));
}
else {
if (level == target.getLevel()) {
return;
}
if (!IntRange.includes(level, 1, 99)) {
pc.sendPackets(new S_SystemMessage("請在1-99範圍內指定"));
return;
}
target.setExp(ExpTable.getExpByLevel(level));
}
}
catch (Exception e) {
pc.sendPackets(new S_SystemMessage(cmdName + " 玩家名稱 請輸入。"));
}
}
}



更動commands資料庫
新增以下指令


QUOTE:

玩家等級100L1Levelid

2013年6月1日 星期六

【Java教學】添加GM指令 線上調整掉寶

將下列原碼新增加到\src\l1j\server\server\command\executor裡面

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
請點此開啟連結或下載檔案
*/
package l1j.server.server.command.executor;

import java.util.StringTokenizer;
import java.util.logging.Logger;

import l1j.server.Config;
import l1j.server.server.model.L1World;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.model.item.L1ItemId;
import l1j.server.server.serverpackets.S_SystemMessage;

public class L1ChangeDrop implements L1CommandExecutor {
   private static Logger _log = Logger.getLogger(L1ChangeDrop.class.getName());

   private L1ChangeDrop() {
   }

   public static L1CommandExecutor getInstance() {
       return new L1ChangeDrop();
   }
   
   //TODO 線上調整掉寶率 by 710410
   private Thread changeExpThread = null;

   //@Override
   public void execute(L1PcInstance pc, String cmdName, String arg) {
       try {
           StringTokenizer st = new StringTokenizer(arg);
           int index = Integer.parseInt(st.nextToken());

           String arg1 = null;
           String arg2 = null;

           if (index >= 0) {
               StringTokenizer token = new StringTokenizer(arg, " ");

               if (token.hasMoreTokens()) {
                   arg1 = token.nextToken().trim();
               }
               if (token.hasMoreTokens()) {
                   arg2 = token.nextToken().trim();
               }
           }

           if (arg1 != null && !arg1.equals("")) {
               final double rateDrop = Double.parseDouble(arg1); 
               final double oldrateDrop = Config.RATE_DROP_ITEMS; 
               if (arg2 != null && !arg2.equals("")) { 
                   final int interval = Integer.parseInt(arg2) * 60 * 1000;
                   if (this.changeExpThread == null) {
                       this.changeExpThread = new Thread() { 
                           public void run() {
                               Config.RATE_DROP_ITEMS = rateDrop; 
                               try { 
                                   sleep(interval); 
                               } catch (Exception e) {
                                   System.out.println(e); 
                               }
                               Config.RATE_DROP_ITEMS = oldrateDrop;
                           } 
                       };
                       this.changeExpThread.start(); 
                   } else {
                       this.changeExpThread.interrupt();

                       this.changeExpThread = new Thread() {
                           public void run() { 
                               Config.RATE_DROP_ITEMS = rateDrop; 
                               try { 
                                   sleep(interval); 
                               } catch (Exception e) {
                                   System.out.println(e); 
                               } 
                               Config.RATE_DROP_ITEMS = oldrateDrop;
                           } 
                       };
                       this.changeExpThread.start(); 
                   } 
               } else {
                   Config.RATE_DROP_ITEMS = rateDrop;
               } 
               try { 
                   Thread.sleep(400);
               } catch (Exception e) {
                   System.out.println(e);
               } 
               L1World.getInstance().broadcastServerMessage( 
                       "系統公告" + ": " + 
                       "掉寶率已調整為" + "【" + Config.RATE_DROP_ITEMS + " 】" + 
                       "倍" + "。");
               pc.sendPackets(new S_SystemMessage( 
                       "掉寶率已調整為" + "【" + Config.RATE_DROP_ITEMS + " 】" + 
                       "倍" + "。"));
           } else { 
               pc.sendPackets(new S_SystemMessage( 
                       "目前的掉寶率為" + "【" + Config.RATE_DROP_ITEMS + " 】" + 
                       "倍" + "。"));
           }
       } catch (Exception e) {
           pc.sendPackets(new S_SystemMessage("請輸入『.drop 倍率』。"));
       }
   }
}


記得DB內要新增掉保指令!!就大功告成囉!!趕快上線測試看看吧!!^^