Kaynağa Gözat

BETA: All Fishes are now in XML instead of SQL '''(by nonom)'''.
* The new FishData class is using the Zoey's DocumentParser abstraction.
* New attributes, so now the fishes have the proper data.
* New fishes and categories that actually are missing.
* Renamed all the old attributes matching the retail names, like groups and grades.
* Added javadocs, cleaned and formatted.

'''NOTE: Require DP [DP8783]'''

MELERIX 13 yıl önce
ebeveyn
işleme
6295cf318d

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java

@@ -49,7 +49,7 @@ import com.l2jserver.gameserver.datatables.EnchantHPBonusData;
 import com.l2jserver.gameserver.datatables.EnchantItemTable;
 import com.l2jserver.gameserver.datatables.EventDroplist;
 import com.l2jserver.gameserver.datatables.ExperienceTable;
-import com.l2jserver.gameserver.datatables.FishTable;
+import com.l2jserver.gameserver.datatables.FishData;
 import com.l2jserver.gameserver.datatables.HelperBuffTable;
 import com.l2jserver.gameserver.datatables.HennaData;
 import com.l2jserver.gameserver.datatables.HerbDropTable;
@@ -228,7 +228,7 @@ public class GameServer
 		MultiSell.getInstance();
 		RecipeController.getInstance();
 		ArmorSetsData.getInstance();
-		FishTable.getInstance();
+		FishData.getInstance();
 		HennaData.getInstance();
 		
 		printSection("Characters");

+ 163 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/FishData.java

@@ -0,0 +1,163 @@
+/*
+ * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.datatables;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import com.l2jserver.gameserver.engines.DocumentParser;
+import com.l2jserver.gameserver.model.L2Fish;
+import com.l2jserver.gameserver.model.StatsSet;
+
+/**
+ * This class holds the Fish information.
+ * @author nonom
+ */
+public final class FishData extends DocumentParser
+{
+	private static final Map<Integer, L2Fish> _fishsNormal = new HashMap<>();
+	private static final Map<Integer, L2Fish> _fishsEasy = new HashMap<>();
+	private static final Map<Integer, L2Fish> _fishsHard = new HashMap<>();
+	
+	private FishData()
+	{
+		_fishsEasy.clear();
+		_fishsNormal.clear();
+		_fishsHard.clear();
+		
+		parseDatapackFile("data/stats/items/fishing/fishes.xml");
+		_log.info(getClass().getSimpleName() + ": Loaded " + (_fishsEasy.size() + _fishsNormal.size() + _fishsHard.size()) + " Fishes.");
+	}
+	
+	@Override
+	protected void parseDocument(Document doc)
+	{
+		NamedNodeMap attrs;
+		Node att;
+		L2Fish fish;
+		StatsSet set;
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
+		{
+			if ("list".equalsIgnoreCase(n.getNodeName()))
+			{
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+				{
+					if ("fish".equalsIgnoreCase(d.getNodeName()))
+					{
+						
+						attrs = d.getAttributes();
+						
+						set = new StatsSet();
+						for (int i = 0; i < attrs.getLength(); i++)
+						{
+							att = attrs.item(i);
+							set.set(att.getNodeName(), att.getNodeValue());
+						}
+						fish = new L2Fish(set);
+						switch (fish.getFishGrade())
+						{
+							case 0:
+							{
+								_fishsEasy.put(fish.getFishId(), fish);
+								break;
+							}
+							case 1:
+							{
+								_fishsNormal.put(fish.getFishId(), fish);
+								break;
+							}
+							case 2:
+							{
+								_fishsHard.put(fish.getFishId(), fish);
+								break;
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	/**
+	 * @param level the fish Level
+	 * @param group the fish Group
+	 * @param grade the fish Grade
+	 * @return List of Fish that can be fished
+	 */
+	public List<L2Fish> getFish(int level, int group, int grade)
+	{
+		ArrayList<L2Fish> result = new ArrayList<L2Fish>();
+		Map<Integer, L2Fish> _Fishs = null;
+		switch (grade)
+		{
+			case 0:
+			{
+				_Fishs = _fishsEasy;
+				break;
+			}
+			case 1:
+			{
+				_Fishs = _fishsNormal;
+				break;
+			}
+			case 2:
+			{
+				_Fishs = _fishsHard;
+				break;
+			}
+		}
+		if (_Fishs == null)
+		{
+			// the fish list is empty
+			_log.warning(getClass().getSimpleName() + ": Fish are not defined !");
+			return null;
+		}
+		for (L2Fish f : _Fishs.values())
+		{
+			if (f.getFishLevel() != level)
+			{
+				continue;
+			}
+			if (f.getFishGroup() != group)
+			{
+				continue;
+			}
+			
+			result.add(f);
+		}
+		if (result.isEmpty())
+		{
+			_log.warning(getClass().getSimpleName() + ": Cant Find Any Fish!? - Lvl: " + level + " Group: " + group + " Grade: " + grade);
+		}
+		return result;
+	}
+	
+	public static FishData getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	@SuppressWarnings("synthetic-access")
+	private static class SingletonHolder
+	{
+		protected static final FishData _instance = new FishData();
+	}
+}

+ 0 - 148
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/FishTable.java

@@ -1,148 +0,0 @@
-/*
- * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.datatables;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javolution.util.FastList;
-
-import com.l2jserver.L2DatabaseFactory;
-import com.l2jserver.gameserver.model.FishData;
-
-/**
- * @author -Nemesiss-
- *
- */
-public class FishTable
-{
-	private static Logger _log = Logger.getLogger(FishTable.class.getName());
-	
-	private static List<FishData> _fishsNormal;
-	private static List<FishData> _fishsEasy;
-	private static List<FishData> _fishsHard;
-	
-	public static FishTable getInstance()
-	{
-		return SingletonHolder._instance;
-	}
-	
-	private FishTable()
-	{
-		//Create table that contains all fish datas
-		int count = 0;
-		Connection con = null;
-		try
-		{
-			con = L2DatabaseFactory.getInstance().getConnection();
-			_fishsEasy = new FastList<FishData>();
-			_fishsNormal = new FastList<FishData>();
-			_fishsHard = new FastList<FishData>();
-			FishData fish;
-			PreparedStatement statement = con.prepareStatement("SELECT id, level, name, hp, hpregen, fish_type, fish_group, fish_guts, guts_check_time, wait_time, combat_time FROM fish ORDER BY id");
-			ResultSet fishes = statement.executeQuery();
-			
-			while (fishes.next())
-			{
-				int id = fishes.getInt("id");
-				int lvl = fishes.getInt("level");
-				String name = fishes.getString("name");
-				int hp = fishes.getInt("hp");
-				int hpreg = fishes.getInt("hpregen");
-				int type = fishes.getInt("fish_type");
-				int group = fishes.getInt("fish_group");
-				int fish_guts = fishes.getInt("fish_guts");
-				int guts_check_time = fishes.getInt("guts_check_time");
-				int wait_time = fishes.getInt("wait_time");
-				int combat_time = fishes.getInt("combat_time");
-				fish = new FishData(id, lvl, name, hp, hpreg, type, group, fish_guts, guts_check_time, wait_time, combat_time);
-				switch (fish.getGroup())
-				{
-					case 0:
-						_fishsEasy.add(fish);
-						break;
-					case 1:
-						_fishsNormal.add(fish);
-						break;
-					case 2:
-						_fishsHard.add(fish);
-				}
-			}
-			fishes.close();
-			statement.close();
-			count = _fishsEasy.size() + _fishsNormal.size() + _fishsHard.size();
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.SEVERE, "Error while creating fish table" + e.getMessage(), e);
-		}
-		finally
-		{
-			L2DatabaseFactory.close(con);
-		}
-		_log.info("FishTable: Loaded " + count + " Fishes.");
-	}
-	
-	/**
-	 * @param lvl
-	 * @param type
-	 * @param group
-	 * @return List of Fish that can be fished
-	 */
-	public List<FishData> getfish(int lvl, int type, int group)
-	{
-		List<FishData> result = new FastList<FishData>();
-		List<FishData> _Fishs = null;
-		switch (group)
-		{
-			case 0:
-				_Fishs = _fishsEasy;
-				break;
-			case 1:
-				_Fishs = _fishsNormal;
-				break;
-			case 2:
-				_Fishs = _fishsHard;
-		}
-		if (_Fishs == null)
-		{
-			// the fish list is empty
-			_log.warning("Fish are not defined !");
-			return null;
-		}
-		for (FishData f : _Fishs)
-		{
-			if (f.getLevel() != lvl)
-				continue;
-			if (f.getType() != type)
-				continue;
-			
-			result.add(f);
-		}
-		if (result.isEmpty())
-			_log.warning("Cant Find Any Fish!? - Lvl: " + lvl + " Type: " + type);
-		return result;
-	}
-	
-	@SuppressWarnings("synthetic-access")
-	private static class SingletonHolder
-	{
-		protected static final FishTable _instance = new FishTable();
-	}
-}

+ 0 - 122
L2J_Server_BETA/java/com/l2jserver/gameserver/model/FishData.java

@@ -1,122 +0,0 @@
-/*
- * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.model;
-
-public class FishData
-{
-	private int _id;
-	private int _level;
-	private String _name;
-	private int _hp;
-	private int _hpRegen;
-	private int _type;
-	private int _group;
-	private int _fishGuts;
-	private int _gutsCheckTime;
-	private int _waitTime;
-	private int _combatTime;
-	
-	public FishData(int id, int lvl, String name, int HP, int HpRegen, int type, int group, int fish_guts, int guts_check_time, int wait_time, int combat_time)
-	{
-		_id = id;
-		_level = lvl;
-		_name = name.intern();
-		_hp = HP;
-		_hpRegen = HpRegen;
-		_type = type;
-		_group = group;
-		_fishGuts = fish_guts;
-		_gutsCheckTime = guts_check_time;
-		_waitTime = wait_time;
-		_combatTime = combat_time;
-	}
-	
-	public FishData(FishData copyOf)
-	{
-		_id = copyOf.getId();
-		_level = copyOf.getLevel();
-		_name = copyOf.getName();
-		_hp = copyOf.getHP();
-		_hpRegen = copyOf.getHpRegen();
-		_type = copyOf.getType();
-		_group = copyOf.getGroup();
-		_fishGuts = copyOf.getFishGuts();
-		_gutsCheckTime = copyOf.getGutsCheckTime();
-		_waitTime = copyOf.getWaitTime();
-		_combatTime = copyOf.getCombatTime();
-	}
-	
-	/**
-	 * @return Returns the id.
-	 */
-	public int getId()
-	{
-		return _id;
-	}
-	
-	/**
-	 * @return Returns the level.
-	 */
-	public int getLevel()
-	{
-		return _level;
-	}
-	
-	/**
-	 * @return Returns the name.
-	 */
-	public String getName()
-	{
-		return _name;
-	}
-	
-	public int getHP()
-	{
-		return _hp;
-	}
-	public int getHpRegen()
-	{
-		return _hpRegen;
-	}
-	public int getType()
-	{
-		return _type;
-	}
-	public int getGroup()
-	{
-		return _group;
-	}
-	public int getFishGuts()
-	{
-		return _fishGuts;
-	}
-	public int getGutsCheckTime()
-	{
-		return _gutsCheckTime;
-	}
-	public int getWaitTime()
-	{
-		return _waitTime;
-	}
-	public int getCombatTime()
-	{
-		return _combatTime;
-	}
-	public void setType(int type)
-	{
-		_type = type;
-	}
-}
-

+ 270 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2Fish.java

@@ -0,0 +1,270 @@
+/*
+ * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.model;
+
+/**
+ * Class for the Fish object.
+ * @author nonom
+ */
+public class L2Fish implements Cloneable
+{
+	private final int _fishId;
+	private final int _itemId;
+	private final String _itemName;
+	private int _fishGroup;
+	private final int _fishLevel;
+	private final double _fishBiteRate;
+	private final double _fishGuts;
+	private final int _fishHp;
+	private final int _fishMaxLength;
+	private final double _fishLengthRate;
+	private final double _hpRegen;
+	private final int _startCombatTime;
+	private final int _combatDuration;
+	private final int _gutsCheckTime;
+	private final double _gutsCheckProbability;
+	private final double _cheatingProb;
+	private final int _fishGrade;
+	
+	public L2Fish(StatsSet set)
+	{
+		_fishId = set.getInteger("fishId");
+		_itemId = set.getInteger("itemId");
+		_itemName = set.getString("itemName");
+		_fishGroup = getGroupId(set.getString("fishGroup"));
+		_fishLevel = set.getInteger("fishLevel");
+		_fishBiteRate = set.getDouble("fishBiteRate"); // TODO: Support needed.
+		_fishGuts = set.getDouble("fishGuts");
+		_fishHp = set.getInteger("fishHp");
+		_fishMaxLength = set.getInteger("fishMaxLength"); // TODO: Support needed.
+		_fishLengthRate = set.getDouble("fishLengthRate"); // TODO: Support needed.
+		_hpRegen = set.getDouble("hpRegen");
+		_startCombatTime = set.getInteger("startCombatTime");
+		_combatDuration = set.getInteger("combatDuration");
+		_gutsCheckTime = set.getInteger("gutsCheckTime");
+		_gutsCheckProbability = set.getDouble("gutsCheckProbability"); // TODO: Support needed.
+		_cheatingProb = set.getDouble("cheatingProb"); // TODO: Support needed.
+		_fishGrade = getGradeId(set.getString("fishGrade"));
+	}
+	
+	@Override
+	public L2Fish clone()
+	{
+		try
+		{
+			return (L2Fish) super.clone();
+		}
+		catch (CloneNotSupportedException e)
+		{
+			return null;
+		}
+	}
+	
+	/**
+	 * @return the fish Id.
+	 */
+	public int getFishId()
+	{
+		return _fishId;
+	}
+	
+	/**
+	 * @return the fish Item Id.
+	 */
+	public int getItemId()
+	{
+		return _itemId;
+	}
+	
+	/**
+	 * @return the fish Item name Id.
+	 */
+	public String getItemName()
+	{
+		return _itemName;
+	}
+	
+	/**
+	 * @return the fish Group.
+	 */
+	public int getFishGroup()
+	{
+		return _fishGroup;
+	}
+	
+	/**
+	 * @return the fish Level.
+	 */
+	public int getFishLevel()
+	{
+		return _fishLevel;
+	}
+	
+	/**
+	 * @return the fish Bite Rate.
+	 */
+	public double getFishBiteRate()
+	{
+		return _fishBiteRate;
+	}
+	
+	/**
+	 * @return the fish Guts.
+	 */
+	public double getFishGuts()
+	{
+		return _fishGuts;
+	}
+	
+	/**
+	 * @return the fish Hp.
+	 */
+	public int getFishHp()
+	{
+		return _fishHp;
+	}
+	
+	/**
+	 * @return the fish Max length.
+	 */
+	public int getFishMaxLength()
+	{
+		return _fishMaxLength;
+	}
+	
+	/**
+	 * @return the fish Length rate.
+	 */	
+	public double getFishLengthRate()
+	{
+		return _fishLengthRate;
+	}
+	
+	/**
+	 * @return the fish Hp regen.
+	 */
+	public double getHpRegen()
+	{
+		return _hpRegen;
+	}
+	
+	/**
+	 * @return the fish start Combat time.
+	 */
+	public int getStartCombatTime()
+	{
+		return _startCombatTime;
+	}
+	
+	/**
+	 * @return the fish Combat duration.
+	 */
+	public int getCombatDuration()
+	{
+		return _combatDuration;
+	}
+	
+	/**
+	 * @return the fish Guts check time.
+	 */
+	public int getGutsCheckTime()
+	{
+		return _gutsCheckTime;
+	}
+	
+	/**
+	 * @return the fish Guts Check probability.
+	 */
+	public double getGutsCheckProbability()
+	{
+		return _gutsCheckProbability;
+	}
+	
+	/**
+	 * @return the fish Cheating prob.
+	 */
+	public double getCheatingProb()
+	{
+		return _cheatingProb;
+	}
+	
+	/**
+	 * @return the fish Grade.
+	 */
+	public int getFishGrade()
+	{
+		return _fishGrade;
+	}
+	
+	/**
+	 * @param fg the fish Group.
+	 */
+	public void setFishGroup(int fg)
+	{
+		_fishGroup = fg;
+	}
+	
+	/**
+	 * @param name the Group Name.
+	 * @return the fish Group Id.
+	 */
+	private int getGroupId(String name)
+	{
+		switch (name)
+		{
+			case "swift":
+				return 1;
+			case "ugly":
+				return 2;
+			case "fish_box":
+				return 3;
+			case "easy_wide":
+				return 4;
+			case "easy_swift":
+				return 5;
+			case "easy_ugly":
+				return 6;
+			case "hard_wide":
+				return 7;
+			case "hard_swift":
+				return 8;
+			case "hard_ugly":
+				return 9;
+			case "hs_fish":
+				return 10; // FIXME: Verify the ID
+			case "wide":
+			default:
+				return 0;
+		}
+	}
+	
+	/**
+	 * @param name the Grade Name.
+	 * @return the fish Grade Id.
+	 */
+	private int getGradeId(String name)
+	{
+		switch (name)
+		{
+			case "fish_easy":
+				return 0;
+			case "fish_hard":
+				return 2;
+			case "fish_normal":
+			default:
+				return 1;
+		}
+	}
+}

+ 95 - 44
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2Fishing.java

@@ -28,7 +28,6 @@ import com.l2jserver.gameserver.network.serverpackets.PlaySound;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.util.Rnd;
 
-
 public class L2Fishing implements Runnable
 {
 	private L2PcInstance _fisher;
@@ -41,20 +40,22 @@ public class L2Fishing implements Runnable
 	private Future<?> _fishAiTask;
 	private boolean _thinking;
 	// Fish datas
-	private int _fishId;
-	private int _fishMaxHp;
+	private final int _fishId;
+	private final int _fishMaxHp;
 	private int _fishCurHp;
-	private double _regenHp;
-	private boolean _isUpperGrade;
+	private final double _regenHp;
+	private final boolean _isUpperGrade;
 	private int _lureType;
 	
 	@Override
 	public void run()
 	{
 		if (_fisher == null)
+		{
 			return;
+		}
 		
-		if (_fishCurHp >= _fishMaxHp * 2)
+		if (_fishCurHp >= (_fishMaxHp * 2))
 		{
 			// The fish got away
 			_fisher.sendPacket(SystemMessageId.BAIT_STOLEN_BY_FISH);
@@ -66,23 +67,28 @@ public class L2Fishing implements Runnable
 			_fisher.sendPacket(SystemMessageId.FISH_SPIT_THE_HOOK);
 			doDie(false);
 		}
-		else aiTask();
+		else
+		{
+			aiTask();
+		}
 	}
 	
-	public L2Fishing(L2PcInstance Fisher, FishData fish, boolean isNoob, boolean isUpperGrade)
+	public L2Fishing(L2PcInstance Fisher, L2Fish fish, boolean isNoob, boolean isUpperGrade)
 	{
 		_fisher = Fisher;
-		_fishMaxHp = fish.getHP();
+		_fishMaxHp = fish.getFishHp();
 		_fishCurHp = _fishMaxHp;
 		_regenHp = fish.getHpRegen();
-		_fishId = fish.getId();
-		_time = fish.getCombatTime() / 1000;
+		_fishId = fish.getItemId();
+		_time = fish.getCombatDuration();
 		_isUpperGrade = isUpperGrade;
-		if (isUpperGrade) {
+		if (isUpperGrade)
+		{
 			_deceptiveMode = Rnd.get(100) >= 90 ? 1 : 0;
 			_lureType = 2;
 		}
-		else {
+		else
+		{
 			_deceptiveMode = 0;
 			_lureType = isNoob ? 0 : 1;
 		}
@@ -104,12 +110,15 @@ public class L2Fishing implements Runnable
 	public void changeHp(int hp, int pen)
 	{
 		_fishCurHp -= hp;
-		if (_fishCurHp < 0) _fishCurHp = 0;
+		if (_fishCurHp < 0)
+		{
+			_fishCurHp = 0;
+		}
 		
 		ExFishingHpRegen efhr = new ExFishingHpRegen(_fisher, _time, _fishCurHp, _mode, _goodUse, _anim, pen, _deceptiveMode);
 		_fisher.broadcastPacket(efhr);
 		_anim = 0;
-		if (_fishCurHp > _fishMaxHp * 2)
+		if (_fishCurHp > (_fishMaxHp * 2))
 		{
 			_fishCurHp = _fishMaxHp * 2;
 			doDie(false);
@@ -130,7 +139,10 @@ public class L2Fishing implements Runnable
 			_fishAiTask = null;
 		}
 		
-		if (_fisher == null) return;
+		if (_fisher == null)
+		{
+			return;
+		}
 		
 		if (win)
 		{
@@ -151,33 +163,48 @@ public class L2Fishing implements Runnable
 	
 	protected void aiTask()
 	{
-		if (_thinking) return;
+		if (_thinking)
+		{
+			return;
+		}
 		_thinking = true;
 		_time--;
 		
 		try
 		{
-			if (_mode == 1) {
+			if (_mode == 1)
+			{
 				if (_deceptiveMode == 0)
+				{
 					_fishCurHp += (int) _regenHp;
+				}
 			}
-			else {
+			else
+			{
 				if (_deceptiveMode == 1)
+				{
 					_fishCurHp += (int) _regenHp;
+				}
 			}
-			if (_stop == 0) {
+			if (_stop == 0)
+			{
 				_stop = 1;
 				int check = Rnd.get(100);
-				if (check >= 70) {
+				if (check >= 70)
+				{
 					_mode = _mode == 0 ? 1 : 0;
 				}
-				if (_isUpperGrade) {
+				if (_isUpperGrade)
+				{
 					check = Rnd.get(100);
 					if (check >= 90)
+					{
 						_deceptiveMode = _deceptiveMode == 0 ? 1 : 0;
+					}
 				}
 			}
-			else {
+			else
+			{
 				_stop--;
 			}
 		}
@@ -186,38 +213,49 @@ public class L2Fishing implements Runnable
 			_thinking = false;
 			ExFishingHpRegen efhr = new ExFishingHpRegen(_fisher, _time, _fishCurHp, _mode, 0, _anim, 0, _deceptiveMode);
 			if (_anim != 0)
+			{
 				_fisher.broadcastPacket(efhr);
+			}
 			else
+			{
 				_fisher.sendPacket(efhr);
+			}
 		}
 	}
 	
 	public void useRealing(int dmg, int pen)
 	{
 		_anim = 2;
-		if (Rnd.get(100) > 90) {
+		if (Rnd.get(100) > 90)
+		{
 			_fisher.sendPacket(SystemMessageId.FISH_RESISTED_ATTEMPT_TO_BRING_IT_IN);
 			_goodUse = 0;
 			changeHp(0, pen);
 			return;
 		}
-		if (_fisher == null) return;
+		if (_fisher == null)
+		{
+			return;
+		}
 		if (_mode == 1)
 		{
-			if (_deceptiveMode == 0) {
+			if (_deceptiveMode == 0)
+			{
 				// Reeling is successful, Damage: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESFUL_S1_DAMAGE);
 				sm.addNumber(dmg);
 				_fisher.sendPacket(sm);
-				if (pen == 50) {
+				if (pen == 50)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_PENALTY_S1);
 					sm.addNumber(pen);
 					_fisher.sendPacket(sm);
 				}
 				_goodUse = 1;
-				changeHp(dmg , pen);
+				changeHp(dmg, pen);
 			}
-			else {
+			else
+			{
 				// Reeling failed, Damage: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.FISH_RESISTED_REELING_S1_HP_REGAINED);
 				sm.addNumber(dmg);
@@ -228,7 +266,8 @@ public class L2Fishing implements Runnable
 		}
 		else
 		{
-			if (_deceptiveMode == 0) {
+			if (_deceptiveMode == 0)
+			{
 				// Reeling failed, Damage: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.FISH_RESISTED_REELING_S1_HP_REGAINED);
 				sm.addNumber(dmg);
@@ -236,18 +275,20 @@ public class L2Fishing implements Runnable
 				_goodUse = 2;
 				changeHp(-dmg, pen);
 			}
-			else {
+			else
+			{
 				// Reeling is successful, Damage: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESFUL_S1_DAMAGE);
 				sm.addNumber(dmg);
 				_fisher.sendPacket(sm);
-				if (pen == 50) {
+				if (pen == 50)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_PENALTY_S1);
 					sm.addNumber(pen);
 					_fisher.sendPacket(sm);
 				}
 				_goodUse = 1;
-				changeHp(dmg , pen);
+				changeHp(dmg, pen);
 			}
 		}
 	}
@@ -255,21 +296,27 @@ public class L2Fishing implements Runnable
 	public void usePomping(int dmg, int pen)
 	{
 		_anim = 1;
-		if (Rnd.get(100) > 90) {
+		if (Rnd.get(100) > 90)
+		{
 			_fisher.sendPacket(SystemMessageId.FISH_RESISTED_ATTEMPT_TO_BRING_IT_IN);
 			_goodUse = 0;
 			changeHp(0, pen);
 			return;
 		}
-		if (_fisher == null) return;
+		if (_fisher == null)
+		{
+			return;
+		}
 		if (_mode == 0)
 		{
-			if (_deceptiveMode == 0) {
+			if (_deceptiveMode == 0)
+			{
 				// Pumping is successful. Damage: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESFUL_S1_DAMAGE);
 				sm.addNumber(dmg);
 				_fisher.sendPacket(sm);
-				if (pen == 50) {
+				if (pen == 50)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_PENALTY_S1);
 					sm.addNumber(pen);
 					_fisher.sendPacket(sm);
@@ -277,7 +324,8 @@ public class L2Fishing implements Runnable
 				_goodUse = 1;
 				changeHp(dmg, pen);
 			}
-			else {
+			else
+			{
 				// Pumping failed, Regained: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.FISH_RESISTED_PUMPING_S1_HP_REGAINED);
 				sm.addNumber(dmg);
@@ -288,7 +336,8 @@ public class L2Fishing implements Runnable
 		}
 		else
 		{
-			if (_deceptiveMode == 0) {
+			if (_deceptiveMode == 0)
+			{
 				// Pumping failed, Regained: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.FISH_RESISTED_PUMPING_S1_HP_REGAINED);
 				sm.addNumber(dmg);
@@ -296,12 +345,14 @@ public class L2Fishing implements Runnable
 				_goodUse = 2;
 				changeHp(-dmg, pen);
 			}
-			else {
+			else
+			{
 				// Pumping is successful. Damage: $s1
 				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESFUL_S1_DAMAGE);
 				sm.addNumber(dmg);
 				_fisher.sendPacket(sm);
-				if (pen == 50) {
+				if (pen == 50)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_PENALTY_S1);
 					sm.addNumber(pen);
 					_fisher.sendPacket(sm);
@@ -314,7 +365,7 @@ public class L2Fishing implements Runnable
 	
 	private void PenaltyMonster()
 	{
-		int lvl = (int)Math.round(_fisher.getLevel()*0.1);
+		int lvl = (int) Math.round(_fisher.getLevel() * 0.1);
 		
 		int npcid;
 		
@@ -360,11 +411,11 @@ public class L2Fishing implements Runnable
 				L2Spawn spawn = new L2Spawn(temp);
 				spawn.setLocx(_fisher.getX());
 				spawn.setLocy(_fisher.getY());
-				spawn.setLocz(_fisher.getZ()+20);
+				spawn.setLocz(_fisher.getZ() + 20);
 				spawn.setAmount(1);
 				spawn.setHeading(_fisher.getHeading());
 				spawn.stopRespawn();
-				((L2PenaltyMonsterInstance)spawn.doSpawn().scheduleDespawn(3*60*1000)).setPlayerToKill(_fisher);
+				((L2PenaltyMonsterInstance) spawn.doSpawn().scheduleDespawn(3 * 60 * 1000)).setPlayerToKill(_fisher);
 			}
 			catch (Exception e)
 			{

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/StatsSet.java

@@ -393,7 +393,7 @@ public final class StatsSet
 	 * @param deflt : float designating the default value if value associated with the key is null
 	 * @return double : value associated to the key
 	 */
-	public double getDouble(String name, float deflt)
+	public double getDouble(String name, double deflt)
 	{
 		Object val = _set.get(name);
 		if (val == null)

+ 59 - 53
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -69,7 +69,7 @@ import com.l2jserver.gameserver.datatables.ClanTable;
 import com.l2jserver.gameserver.datatables.ClassListData;
 import com.l2jserver.gameserver.datatables.EnchantGroupsTable;
 import com.l2jserver.gameserver.datatables.ExperienceTable;
-import com.l2jserver.gameserver.datatables.FishTable;
+import com.l2jserver.gameserver.datatables.FishData;
 import com.l2jserver.gameserver.datatables.HennaData;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.datatables.NpcTable;
@@ -97,7 +97,7 @@ import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
 import com.l2jserver.gameserver.instancemanager.ZoneManager;
 import com.l2jserver.gameserver.model.BlockList;
 import com.l2jserver.gameserver.model.CharEffectList;
-import com.l2jserver.gameserver.model.FishData;
+import com.l2jserver.gameserver.model.L2Fish;
 import com.l2jserver.gameserver.model.L2AccessLevel;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2ClanMember;
@@ -10207,14 +10207,15 @@ public final class L2PcInstance extends L2Playable
 	private class LookingForFishTask implements Runnable
 	{
 		boolean _isNoob, _isUpperGrade;
-		int _fishType, _fishGutsCheck;
+		int _fishGroup;
+		double _fishGutsCheck;
 		long _endTaskTime;
 		
-		protected LookingForFishTask(int fishWaitTime, int fishGutsCheck, int fishType, boolean isNoob, boolean isUpperGrade)
+		protected LookingForFishTask(int startCombatTime, double fishGutsCheck, int fishGroup, boolean isNoob, boolean isUpperGrade)
 		{
 			_fishGutsCheck = fishGutsCheck;
-			_endTaskTime = System.currentTimeMillis() + fishWaitTime + 10000;
-			_fishType = fishType;
+			_endTaskTime = System.currentTimeMillis() + (startCombatTime * 1000) + 10000;
+			_fishGroup = fishGroup;
 			_isNoob = isNoob;
 			_isUpperGrade = isUpperGrade;
 		}
@@ -10226,9 +10227,9 @@ public final class L2PcInstance extends L2Playable
 				endFishing(false);
 				return;
 			}
-			if (_fishType == -1)
+			if (_fishGroup == -1)
 				return;
-			int check = Rnd.get(1000);
+			int check = Rnd.get(100);
 			if(_fishGutsCheck > check)
 			{
 				stopLookingForFishTask();
@@ -12316,7 +12317,7 @@ public final class L2PcInstance extends L2Playable
 		}
 	}
 	
-	private FishData _fish;
+	private L2Fish _fish;
 	
 	/*  startFishing() was stripped of any pre-fishing related checks, namely the fishing zone check.
 	 * Also worthy of note is the fact the code to find the hook landing position was also striped. The
@@ -12336,10 +12337,10 @@ public final class L2PcInstance extends L2Playable
 		_fishz = _z;
 		//broadcastUserInfo();
 		//Starts fishing
-		int lvl = GetRandomFishLvl();
-		int group = GetRandomGroup();
-		int type = GetRandomFishType(group);
-		List<FishData> fishs = FishTable.getInstance().getfish(lvl, type, group);
+		int lvl = getRandomFishLvl();
+		int grade = getRandomFishGrade();
+		int group = getRandomFishGroup(grade);
+		List<L2Fish> fishs = FishData.getInstance().getFish(lvl, group, grade);
 		if (fishs == null || fishs.isEmpty())
 		{
 			sendMessage("Error - Fishes are not definied");
@@ -12348,14 +12349,14 @@ public final class L2PcInstance extends L2Playable
 		}
 		int check = Rnd.get(fishs.size());
 		// Use a copy constructor else the fish data may be over-written below
-		_fish = new FishData(fishs.get(check));
+		_fish = fishs.get(check).clone();
 		fishs.clear();
 		fishs = null;
 		sendPacket(SystemMessageId.CAST_LINE_AND_START_FISHING);
 		if (!GameTimeController.getInstance().isNowNight() && _lure.isNightLure())
-			_fish.setType(-1);
+			_fish.setFishGroup(-1);
 		//sendMessage("Hook x,y: " + _x + "," + _y + " - Water Z, Player Z:" + _z + ", " + getZ()); //debug line, uncoment to show coordinates used in fishing.
-		broadcastPacket(new ExFishingStart(this,_fish.getType(),_x,_y,_z,_lure.isNightLure()));
+		broadcastPacket(new ExFishingStart(this,_fish.getFishGroup(),_x,_y,_z,_lure.isNightLure()));
 		sendPacket(new PlaySound(1, "SF_P_01", 0, 0, 0, 0, 0));
 		startLookingForFishTask();
 	}
@@ -12378,44 +12379,47 @@ public final class L2PcInstance extends L2Playable
 			if (_lure != null)
 			{
 				int lureid = _lure.getItemId();
-				isNoob = _fish.getGroup() == 0;
-				isUpperGrade = _fish.getGroup() == 2;
+				isNoob = _fish.getFishGrade() == 0;
+				isUpperGrade = _fish.getFishGrade() == 2;
 				if (lureid == 6519 || lureid == 6522 || lureid == 6525 || lureid == 8505 || lureid == 8508 || lureid == 8511) //low grade
-					checkDelay = Math.round((float)(_fish.getGutsCheckTime() * (1.33)));
+					checkDelay = Math.round(_fish.getGutsCheckTime() * (133));
 				else if (lureid == 6520 || lureid == 6523 || lureid == 6526 || (lureid >= 8505 && lureid <= 8513) || (lureid >= 7610 && lureid <= 7613) || (lureid >= 7807 && lureid <= 7809) || (lureid >= 8484 && lureid <= 8486)) //medium grade, beginner, prize-winning & quest special bait
-					checkDelay = Math.round((float)(_fish.getGutsCheckTime() * (1.00)));
+					checkDelay = Math.round(_fish.getGutsCheckTime() * (100));
 				else if (lureid == 6521 || lureid == 6524 || lureid == 6527 || lureid == 8507 || lureid == 8510 || lureid == 8513) //high grade
-					checkDelay = Math.round((float)(_fish.getGutsCheckTime() * (0.66)));
+					checkDelay = Math.round(_fish.getGutsCheckTime() * (66));
 			}
-			_taskforfish = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new LookingForFishTask(_fish.getWaitTime(), _fish.getFishGuts(), _fish.getType(), isNoob, isUpperGrade), 10000, checkDelay);
+			_taskforfish = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new LookingForFishTask(_fish.getStartCombatTime(), _fish.getFishGuts(), _fish.getFishGroup(), isNoob, isUpperGrade), 10000, checkDelay);
 		}
 	}
 	
-	private int GetRandomGroup()
+	private int getRandomFishGrade()
 	{
-		switch (_lure.getItemId()) {
-			case 7807: //green for beginners
-			case 7808: //purple for beginners
-			case 7809: //yellow for beginners
-			case 8486: //prize-winning for beginners
+		switch (_lure.getItemId())
+		{
+			case 7807: // green for beginners
+			case 7808: // purple for beginners
+			case 7809: // yellow for beginners
+			case 8486: // prize-winning for beginners
 				return 0;
-			case 8485: //prize-winning luminous
-			case 8506: //green luminous
-			case 8509: //purple luminous
-			case 8512: //yellow luminous
+			case 8485: // prize-winning luminous
+			case 8506: // green luminous
+			case 8509: // purple luminous
+			case 8512: // yellow luminous
 				return 2;
 			default:
 				return 1;
 		}
 	}
-	private int GetRandomFishType(int group)
+	private int getRandomFishGroup(int group)
 	{
 		int check = Rnd.get(100);
 		int type = 1;
-		switch (group) {
-			case 0:	//fish for novices
-				switch (_lure.getItemId()) {
-					case 7807: //green lure, preferred by fast-moving (nimble) fish (type 5)
+		switch (group)
+		{
+			case 0: // fish for novices
+				switch (_lure.getItemId())
+				{
+					case 7807: // green lure, preferred by fast-moving (nimble) fish (type 5)
 						if (check <= 54)
 							type = 5;
 						else if (check <= 77)
@@ -12423,7 +12427,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 6;
 						break;
-					case 7808: //purple lure, preferred by fat fish (type 4)
+					case 7808: // purple lure, preferred by fat fish (type 4)
 						if (check <= 54)
 							type = 4;
 						else if (check <= 77)
@@ -12431,7 +12435,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 5;
 						break;
-					case 7809: //yellow lure, preferred by ugly fish (type 6)
+					case 7809: // yellow lure, preferred by ugly fish (type 6)
 						if (check <= 54)
 							type = 6;
 						else if (check <= 77)
@@ -12439,7 +12443,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 4;
 						break;
-					case 8486:	//prize-winning fishing lure for beginners
+					case 8486: // prize-winning fishing lure for beginners
 						if (check <= 33)
 							type = 4;
 						else if (check <= 66)
@@ -12449,15 +12453,16 @@ public final class L2PcInstance extends L2Playable
 						break;
 				}
 				break;
-			case 1:	//normal fish
-				switch (_lure.getItemId()) {
+			case 1: // normal fish
+				switch (_lure.getItemId())
+				{
 					case 7610:
 					case 7611:
 					case 7612:
 					case 7613:
 						type = 3;
 						break;
-					case 6519:  //all theese lures (green) are prefered by fast-moving (nimble) fish (type 1)
+					case 6519: // all theese lures (green) are prefered by fast-moving (nimble) fish (type 1)
 					case 8505:
 					case 6520:
 					case 6521:
@@ -12471,7 +12476,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 3;
 						break;
-					case 6522:	 //all theese lures (purple) are prefered by fat fish (type 0)
+					case 6522: // all theese lures (purple) are prefered by fat fish (type 0)
 					case 8508:
 					case 6523:
 					case 6524:
@@ -12485,7 +12490,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 3;
 						break;
-					case 6525:	//all theese lures (yellow) are prefered by ugly fish (type 2)
+					case 6525: // all theese lures (yellow) are prefered by ugly fish (type 2)
 					case 8511:
 					case 6526:
 					case 6527:
@@ -12499,7 +12504,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 3;
 						break;
-					case 8484:	//prize-winning fishing lure
+					case 8484: // prize-winning fishing lure
 						if (check <= 33)
 							type = 0;
 						else if (check <= 66)
@@ -12509,9 +12514,10 @@ public final class L2PcInstance extends L2Playable
 						break;
 				}
 				break;
-			case 2:	//upper grade fish, luminous lure
-				switch (_lure.getItemId()) {
-					case 8506: //green lure, preferred by fast-moving (nimble) fish (type 8)
+			case 2: // upper grade fish, luminous lure
+				switch (_lure.getItemId())
+				{
+					case 8506: // green lure, preferred by fast-moving (nimble) fish (type 8)
 						if (check <= 54)
 							type = 8;
 						else if (check <= 77)
@@ -12519,7 +12525,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 9;
 						break;
-					case 8509: //purple lure, preferred by fat fish (type 7)
+					case 8509: // purple lure, preferred by fat fish (type 7)
 						if (check <= 54)
 							type = 7;
 						else if (check <= 77)
@@ -12527,7 +12533,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 8;
 						break;
-					case 8512: //yellow lure, preferred by ugly fish (type 9)
+					case 8512: // yellow lure, preferred by ugly fish (type 9)
 						if (check <= 54)
 							type = 9;
 						else if (check <= 77)
@@ -12535,7 +12541,7 @@ public final class L2PcInstance extends L2Playable
 						else
 							type = 7;
 						break;
-					case 8485: //prize-winning fishing lure
+					case 8485: // prize-winning fishing lure
 						if (check <= 33)
 							type = 7;
 						else if (check <= 66)
@@ -12547,7 +12553,7 @@ public final class L2PcInstance extends L2Playable
 		}
 		return type;
 	}
-	private int GetRandomFishLvl()
+	private int getRandomFishLvl()
 	{
 		int skilllvl = getSkillLevel(1315);
 		final L2Effect e = getFirstEffect(2274);