⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l1merchantinstance.java

📁 网络游戏天堂1的java源代码。。。。。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * 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.model.Instance;

import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;

import l1j.server.server.datatables.NPCTalkDataTable;
import l1j.server.server.datatables.TownTable;
import l1j.server.server.model.L1Attack;
import l1j.server.server.model.L1CastleLocation;
import l1j.server.server.model.L1Clan;
import l1j.server.server.model.L1NpcTalkData;
import l1j.server.server.model.L1Quest;
import l1j.server.server.model.L1TownLocation;
import l1j.server.server.model.L1World;
import l1j.server.server.model.Instance.L1QuestInstance.RestMonitor;
import l1j.server.server.model.gametime.L1GameTimeClock;
import l1j.server.server.serverpackets.S_NPCTalkReturn;
import l1j.server.server.serverpackets.S_ServerMessage;
import l1j.server.server.templates.L1Npc;
import l1j.server.server.serverpackets.S_ChangeHeading;

public class L1MerchantInstance extends L1NpcInstance {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static l1j.eric.EricLogger _log =  l1j.eric.EricLogger.getLogger2(L1MerchantInstance.class
			.getName());

	/**
	 * @param template
	 */
	public L1MerchantInstance(L1Npc template) {
		super(template);
	}

	@Override
	public void onAction(L1PcInstance pc) {
		L1Attack attack = new L1Attack(pc, this);
		attack.calcHit();
		attack.action();
	}
	
	@Override
	public void onNpcAI() {
		if (isAiRunning()) {
			return;
		}
		setActived(false);
		startAI();
	}

	@Override
	public void onTalkAction(L1PcInstance player) {
		int objid = getId();
		L1NpcTalkData talking = NPCTalkDataTable.getInstance().getTemplate(
				getNpcTemplate().get_npcId());
		int npcid = getNpcTemplate().get_npcId();
		L1Quest quest = player.getQuest();
		String htmlid = null;
		String[] htmldata = null;

		int pcX = player.getX();
		int pcY = player.getY();
		int npcX = getX();
		int npcY = getY();

		if(getNpcTemplate().getChangeHead()) {
			if (pcX == npcX && pcY < npcY) {
				setHeading(0);
			} else if (pcX > npcX && pcY < npcY) {
				setHeading(1);
			} else if (pcX > npcX && pcY == npcY) {
				setHeading(2);
			} else if (pcX > npcX && pcY > npcY) {
				setHeading(3);
			} else if (pcX == npcX && pcY > npcY) {
				setHeading(4);
			} else if (pcX < npcX && pcY > npcY) {
				setHeading(5);
			} else if (pcX < npcX && pcY == npcY) {
				setHeading(6);
			} else if (pcX < npcX && pcY < npcY) {
				setHeading(7);
			}
			broadcastPacket(new S_ChangeHeading(this));

			synchronized (this) {
				if (_monitor != null) {
					_monitor.cancel();
				}
				setRest(true);
				_monitor = new RestMonitor();
				_restTimer.schedule(_monitor, REST_MILLISEC);
			}
		}
	
		if (talking != null) {
			if (npcid == 70841) { // ルーディエル
				if (player.isElf()) { // エルフ
					htmlid = "luudielE1";
				} else if (player.isDarkelf()) { // ダークエルフ
					htmlid = "luudielCE1";
				} else {
					htmlid = "luudiel1";
				}
			} else if (npcid == 70522) { // グンター
				if (player.isCrown()) { // 君主
					if (player.getLevel() >= 15) {
						int lv15_step = quest.get_step(L1Quest.QUEST_LEVEL15);
						if (lv15_step == 2 || lv15_step == L1Quest.QUEST_END) { // クリア済み
							htmlid = "gunterp11";
						} else {
							htmlid = "gunterp9";
						}
					} else { // Lv15未満
						htmlid = "gunterp12";
					}
				} else if (player.isKnight()) { // ナイト
					int lv30_step = quest.get_step(L1Quest.QUEST_LEVEL30);
					if (lv30_step == 0) { // 未開始
						htmlid = "gunterk9";
					} else if (lv30_step == 1) {
						htmlid = "gunterkE1";
					} else if (lv30_step == 2) { // グンター同意済み
						htmlid = "gunterkE2";
					} else if (lv30_step >= 3) { // グンター終了済み
						htmlid = "gunterkE3";
					}
				} else if (player.isElf()) { // エルフ
					htmlid = "guntere1";
				} else if (player.isWizard()) { // ウィザード
					htmlid = "gunterw1";
				} else if (player.isDarkelf()) { // ダークエルフ
					htmlid = "gunterde1";
				}
			} else if (npcid == 70653) { // マシャー
				if (player.isCrown()) { // 君主
					if (player.getLevel() >= 45) {
						if (quest.isEnd(L1Quest.QUEST_LEVEL30)) { // lv30クリア済み
							int lv45_step = quest
									.get_step(L1Quest.QUEST_LEVEL45);
							if (lv45_step == L1Quest.QUEST_END) { // クリア済み
								htmlid = "masha4";
							} else if (lv45_step >= 1) { // 同意済み
								htmlid = "masha3";
							} else { // 未同意
								htmlid = "masha1";
							}
						}
					}
				} else if (player.isKnight()) { // ナイト
					if (player.getLevel() >= 45) {
						if (quest.isEnd(L1Quest.QUEST_LEVEL30)) { // Lv30クエスト終了済み
							int lv45_step = quest
									.get_step(L1Quest.QUEST_LEVEL45);
							if (lv45_step == L1Quest.QUEST_END) { // クリア済み
								htmlid = "mashak3";
							} else if (lv45_step == 0) { // 未開始
								htmlid = "mashak1";
							} else if (lv45_step >= 1) { // 同意済み
								htmlid = "mashak2";
							}
						}
					}
				} else if (player.isElf()) { // エルフ
					if (player.getLevel() >= 45) {
						if (quest.isEnd(L1Quest.QUEST_LEVEL30)) { // Lv30クエスト終了済み
							int lv45_step = quest
									.get_step(L1Quest.QUEST_LEVEL45);
							if (lv45_step == L1Quest.QUEST_END) { // クリア済み
								htmlid = "mashae3";
							} else if (lv45_step >= 1) { // 同意済み
								htmlid = "mashae2";
							} else { // 未同意
								htmlid = "mashae1";
							}
						}
					}
				}
			} else if (npcid == 70554) { // ゼロ
				if (player.isCrown()) { // 君主
					if (player.getLevel() >= 15) {
						int lv15_step = quest.get_step(L1Quest.QUEST_LEVEL15);
						if (lv15_step == 1) { // ゼロクリア済み
							htmlid = "zero5";
						} else if (lv15_step == L1Quest.QUEST_END) { // ゼロ、グンタークリア済み
							htmlid = "zero1";// 6
						} else {
							htmlid = "zero1";
						}
					} else { // Lv15未満
						htmlid = "zero6";
					}
				}
			} else if (npcid == 70783) { // アリア
				if (player.isCrown()) { // 君主
					if (player.getLevel() >= 30) {
						if (quest.isEnd(L1Quest.QUEST_LEVEL15)) { // lv15試練クリア済み
							int lv30_step = quest
									.get_step(L1Quest.QUEST_LEVEL30);
							if (lv30_step == L1Quest.QUEST_END) { // クリア済み
								htmlid = "aria3";
							} else if (lv30_step == 1) { // 同意済み
								htmlid = "aria2";
							} else { // 未同意
								htmlid = "aria1";
							}
						}
					}
				}
			} else if (npcid == 70782) { // サーチアント
				if (player.getTempCharGfx() == 1037) {// ジャイアントアント変身
					if (player.isCrown()) { // 君主
						if (quest.get_step(L1Quest.QUEST_LEVEL30) == 1) {
							htmlid = "ant1";
						} else {
							htmlid = "ant3";
						}
					} else { // 君主以外
						htmlid = "ant3";
					}
				}
			} else if (npcid == 70545) { // リチャード
				if (player.isCrown()) { // 君主
					int lv45_step = quest.get_step(L1Quest.QUEST_LEVEL45);
					if (lv45_step >= 1 && lv45_step != L1Quest.QUEST_END) { // 開始かつ未終了
						if (player.getInventory().checkItem(40586)) { // 王家の紋章(左)
							htmlid = "richard4";
						} else {
							htmlid = "richard1";
						}
					}
				}
			} else if (npcid == 70776) { // メグ
				if (player.isCrown()) { // 君主
					int lv45_step = quest.get_step(L1Quest.QUEST_LEVEL45);
					if (lv45_step == 1) {
						htmlid = "meg1";
					} else if (lv45_step == 2 && lv45_step <= 3 ) { // メグ同意済み
						htmlid = "meg2";
					} else if (lv45_step >= 4) { // メグクリア済み
						htmlid = "meg3";
					}
				}
			} else if (npcid == 71200) { // 白魔術師 ピエタ
				if (player.isCrown()) { // 君主
					int lv45_step = quest.get_step(L1Quest.QUEST_LEVEL45);
					if (lv45_step == 2 && player.getInventory().checkItem(41422)) {	
						player.getInventory().consumeItem(41422, 1);
						final int[] item_ids = { 40568 };
						final int[] item_amounts = { 1 };
						for (int i = 0; i < item_ids.length; i++) {
							player.getInventory().storeItem(
									item_ids[i], item_amounts[i]);
						}
					}
				}
			// } else if (npcid == 71200) { // 白魔術師 ピエタ
				// if (player.isCrown()) { // 君主
					// int lv45_step = quest.get_step(L1Quest.QUEST_LEVEL45);
					// if (lv45_step >= 6 && lv45_step == L1Quest.QUEST_END ) {
					// //メグクリア済みor終了
						// htmlid = "pieta9";
					// } else if (lv45_step == 2) { // クエスト開始前・メグ同意済み
						// htmlid = "pieta2";
					// } else if (lv45_step == 2 ||
								// player.getInventory().checkItem(41422) ) {//
								// 輝きを失った魂保持
						// htmlid = "pieta4";
					// } else if (lv45_step == 3) { // 輝きを失った魂入後
						// htmlid = "pieta6";
					// } else {//lv45未満orクエスト30未
						// htmlid = "pieta8";
					// }
				// } else { // 君主以外
					// htmlid = "pieta1";
				// }
			// } else if (npcid == 70751) { // ブラッド
				// if (player.isCrown()) { // 君主
					// if (player.getLevel() >= 45) {
						// if (quest.get_step(L1Quest.QUEST_LEVEL45) == 2) { //
						// メグ同意済み
							// htmlid = "brad1";
						// }
					// }
				// }
			} else if (npcid == 70798) { // リッキー
				if (player.isKnight()) { // ナイト
					if (player.getLevel() >= 15) {
						int lv15_step = quest.get_step(L1Quest.QUEST_LEVEL15);
						if (lv15_step >= 1) { // リッキークリア済み
							htmlid = "riky5";
						} else {
							htmlid = "riky1";
						}
					} else { // Lv15未満
						htmlid = "riky6";
					}
				}
			} else if (npcid == 70802) { // アノン
				if (player.isKnight()) { // ナイト
					if (player.getLevel() >= 15) {
						int lv15_step = quest.get_step(L1Quest.QUEST_LEVEL15);
						if (lv15_step == L1Quest.QUEST_END) { // アノンクリア済み
							htmlid = "aanon7";
						} else if (lv15_step == 1) { // リッキークリア済み
							htmlid = "aanon4";
						}
					}
				}
			} else if (npcid == 70775) { // マーク
				if (player.isKnight()) { // ナイト
					if (player.getLevel() >= 30) {
						if (quest.isEnd(L1Quest.QUEST_LEVEL15)) { // LV15クエスト終了済み
							int lv30_step = quest
									.get_step(L1Quest.QUEST_LEVEL30);
							if (lv30_step == 0) { // 未開始
								htmlid = "mark1";
							} else {
								htmlid = "mark2";
							}
						}
					}
				}
			} else if (npcid == 70794) { // ゲラド
				if (player.isCrown()) { // 君主
					htmlid = "gerardp1";
				} else if (player.isKnight()) { // ナイト
					int lv30_step = quest.get_step(L1Quest.QUEST_LEVEL30);
					if (lv30_step == L1Quest.QUEST_END) { // ゲラド終了済み
						htmlid = "gerardkEcg";
					} else if (lv30_step < 3) { // グンター未終了
						htmlid = "gerardk7";
					} else if (lv30_step == 3) { // グンター終了済み
						htmlid = "gerardkE1";
					} else if (lv30_step == 4) { // ゲラド同意済み
						htmlid = "gerardkE2";
					} else if (lv30_step == 5) { // ラミアの鱗 終了済み
						htmlid = "gerardkE3";
					} else if (lv30_step >= 6) { // 復活のポーション同意済み
						htmlid = "gerardkE4";
					}
				} else if (player.isElf()) { // エルフ

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -