Project update.

This commit is contained in:
MobiusDev
2015-12-31 23:53:41 +00:00
parent e0d681a17e
commit ad2bcd79be
4084 changed files with 83696 additions and 86998 deletions

View File

@@ -0,0 +1,322 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.model.fishing;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* 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;
private static long _fishExp;
private static long _fishSp;
public L2Fish(StatsSet set)
{
_fishId = set.getInt("fishId");
_itemId = set.getInt("itemId");
_itemName = set.getString("itemName");
_fishGroup = getGroupId(set.getString("fishGroup"));
_fishLevel = set.getInt("fishLevel");
_fishBiteRate = set.getDouble("fishBiteRate"); // TODO: Support needed.
_fishGuts = set.getDouble("fishGuts");
_fishHp = set.getInt("fishHp");
_fishMaxLength = set.getInt("fishMaxLength"); // TODO: Support needed.
_fishLengthRate = set.getDouble("fishLengthRate"); // TODO: Support needed.
_hpRegen = set.getDouble("hpRegen");
_startCombatTime = set.getInt("startCombatTime");
_combatDuration = set.getInt("combatDuration");
_gutsCheckTime = set.getInt("gutsCheckTime");
_gutsCheckProbability = set.getDouble("gutsCheckProbability"); // TODO: Support needed.
_cheatingProb = set.getDouble("cheatingProb"); // TODO: Support needed.
_fishGrade = getGradeId(set.getString("fishGrade"));
_fishExp = set.getLong("fishExp");
_fishSp = set.getLong("fishSp");
}
@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;
}
/**
* @return the fish Exp.
*/
public Long getExp()
{
return _fishExp;
}
/**
* @return the fish Sp.
*/
public Long getSp()
{
return _fishSp;
}
/**
* @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;
}
}
}
}

View File

@@ -0,0 +1,377 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.model.fishing;
import java.util.concurrent.Future;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.FishingMonstersData;
import com.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.AbstractScript;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExFishingHpRegen;
import com.l2jmobius.gameserver.network.serverpackets.ExFishingStartCombat;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.util.Rnd;
public class L2Fishing implements Runnable
{
private L2PcInstance _fisher;
private int _time;
private int _stop = 0;
private int _goodUse = 0;
private int _anim = 0;
private int _mode = 0;
private int _deceptiveMode = 0;
private Future<?> _fishAiTask;
private boolean _thinking;
// Fish datas
private final int _fishId;
private final int _fishMaxHp;
private int _fishCurHp;
private final double _regenHp;
private final boolean _isUpperGrade;
private final int _lureId;
@Override
public void run()
{
if (_fisher == null)
{
return;
}
if (_fishCurHp >= (_fishMaxHp * 2))
{
// The fish got away
_fisher.sendPacket(SystemMessageId.YOUR_BAIT_WAS_STOLEN_BY_THAT_FISH);
doDie(false);
}
else if (_time <= 0)
{
// Time is up, so that fish got away
_fisher.sendPacket(SystemMessageId.THAT_FISH_IS_MORE_DETERMINED_THAN_YOU_ARE_IT_SPIT_THE_HOOK);
doDie(false);
}
else
{
aiTask();
}
}
public L2Fishing(L2PcInstance Fisher, L2Fish fish, boolean isNoob, boolean isUpperGrade, int lureId)
{
_fisher = Fisher;
_fishMaxHp = fish.getFishHp();
_fishCurHp = _fishMaxHp;
_regenHp = fish.getHpRegen();
_fishId = fish.getItemId();
_time = fish.getCombatDuration();
_isUpperGrade = isUpperGrade;
_lureId = lureId;
final int lureType;
if (isUpperGrade)
{
_deceptiveMode = ((Rnd.get(100) >= 90) ? 1 : 0);
lureType = 2;
}
else
{
_deceptiveMode = 0;
lureType = (isNoob ? 0 : 1);
}
_mode = ((Rnd.get(100) >= 80) ? 1 : 0);
_fisher.broadcastPacket(new ExFishingStartCombat(_fisher, _time, _fishMaxHp, _mode, lureType, _deceptiveMode));
_fisher.sendPacket(new PlaySound(1, "SF_S_01", 0, 0, 0, 0, 0));
// Succeeded in getting a bite
// _fisher.sendPacket(SystemMessageId.YOU_VE_GOT_A_BITE);
if ((_fishAiTask == null) && _fisher.isFishing())
{
_fishAiTask = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(this, 1000, 1000);
}
// TODO: New fishing system?
doDie(true);
}
public void changeHp(int hp, int pen)
{
_fishCurHp -= hp;
if (_fishCurHp < 0)
{
_fishCurHp = 0;
}
_fisher.broadcastPacket(new ExFishingHpRegen(_fisher, _time, _fishCurHp, _mode, _goodUse, _anim, pen, _deceptiveMode));
_anim = 0;
if (_fishCurHp > (_fishMaxHp * 2))
{
_fishCurHp = _fishMaxHp * 2;
doDie(false);
return;
}
else if (_fishCurHp == 0)
{
doDie(true);
return;
}
}
public synchronized void doDie(boolean win)
{
if (_fishAiTask != null)
{
_fishAiTask.cancel(false);
_fishAiTask = null;
}
if (_fisher == null)
{
return;
}
if (win)
{
final L2FishingMonster fishingMonster = FishingMonstersData.getInstance().getFishingMonster(_fisher.getLevel());
if (fishingMonster != null)
{
if (Rnd.get(100) <= fishingMonster.getProbability())
{
_fisher.sendPacket(SystemMessageId.YOU_VE_CAUGHT_GOLDEEN);
final L2Npc monster = AbstractScript.addSpawn(fishingMonster.getFishingMonsterId(), _fisher);
monster.setTarget(_fisher);
}
else
{
_fisher.sendPacket(SystemMessageId.YOU_CAUGHT_SOMETHING);
_fisher.addItem("Fishing", _fishId, 1, null, true);
FishingChampionshipManager.getInstance().newFish(_fisher, _lureId);
}
}
}
_fisher.endFishing(win, true);
_fisher = null;
}
protected void aiTask()
{
if (_thinking)
{
return;
}
_thinking = true;
_time--;
try
{
if (_mode == 1)
{
if (_deceptiveMode == 0)
{
_fishCurHp += (int) _regenHp;
}
}
else
{
if (_deceptiveMode == 1)
{
_fishCurHp += (int) _regenHp;
}
}
if (_stop == 0)
{
_stop = 1;
int check = Rnd.get(100);
if (check >= 70)
{
_mode = _mode == 0 ? 1 : 0;
}
if (_isUpperGrade)
{
check = Rnd.get(100);
if (check >= 90)
{
_deceptiveMode = _deceptiveMode == 0 ? 1 : 0;
}
}
}
else
{
_stop--;
}
}
finally
{
_thinking = false;
final ExFishingHpRegen efhr = new ExFishingHpRegen(_fisher, _time, _fishCurHp, _mode, 0, _anim, 0, _deceptiveMode);
if (_anim != 0)
{
_fisher.broadcastPacket(efhr);
}
else
{
_fisher.sendPacket(efhr);
}
}
}
public void useReeling(int dmg, int pen)
{
_anim = 2;
if (Rnd.get(100) > 90)
{
_fisher.sendPacket(SystemMessageId.THE_FISH_HAS_RESISTED_YOUR_ATTEMPT_TO_BRING_IT_IN);
_goodUse = 0;
changeHp(0, pen);
return;
}
if (_fisher == null)
{
return;
}
if (_mode == 1)
{
if (_deceptiveMode == 0)
{
// Reeling is successful, Damage: $s1
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_REEL_THAT_FISH_IN_CLOSER_AND_CAUSE_S1_DAMAGE);
sm.addInt(dmg);
_fisher.sendPacket(sm);
if (pen > 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_MASTERY_PENALTY_S1);
sm.addInt(pen);
_fisher.sendPacket(sm);
}
_goodUse = 1;
changeHp(dmg, pen);
}
else
{
// Reeling failed, Damage: $s1
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FAILED_TO_REEL_THAT_FISH_IN_FURTHER_AND_IT_REGAINS_S1_HP);
sm.addInt(dmg);
_fisher.sendPacket(sm);
_goodUse = 2;
changeHp(-dmg, pen);
}
}
else
{
if (_deceptiveMode == 0)
{
// Reeling failed, Damage: $s1
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FAILED_TO_REEL_THAT_FISH_IN_FURTHER_AND_IT_REGAINS_S1_HP);
sm.addInt(dmg);
_fisher.sendPacket(sm);
_goodUse = 2;
changeHp(-dmg, pen);
}
else
{
// Reeling is successful, Damage: $s1
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_REEL_THAT_FISH_IN_CLOSER_AND_CAUSE_S1_DAMAGE);
sm.addInt(dmg);
_fisher.sendPacket(sm);
if (pen > 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_MASTERY_PENALTY_S1);
sm.addInt(pen);
_fisher.sendPacket(sm);
}
_goodUse = 1;
changeHp(dmg, pen);
}
}
}
public void usePumping(int dmg, int pen)
{
_anim = 1;
if (Rnd.get(100) > 90)
{
_fisher.sendPacket(SystemMessageId.THE_FISH_HAS_RESISTED_YOUR_ATTEMPT_TO_BRING_IT_IN);
_goodUse = 0;
changeHp(0, pen);
return;
}
if (_fisher == null)
{
return;
}
if (_mode == 0)
{
if (_deceptiveMode == 0)
{
// Pumping is successful. Damage: $s1
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_PUMPING_IS_SUCCESSFUL_CAUSING_S1_DAMAGE);
sm.addInt(dmg);
_fisher.sendPacket(sm);
if (pen > 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_MASTERY_PENALTY_S1);
sm.addInt(pen);
_fisher.sendPacket(sm);
}
_goodUse = 1;
changeHp(dmg, pen);
}
else
{
// Pumping failed, Regained: $s1
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FAILED_TO_DO_ANYTHING_WITH_THE_FISH_AND_IT_REGAINS_S1_HP);
sm.addInt(dmg);
_fisher.sendPacket(sm);
_goodUse = 2;
changeHp(-dmg, pen);
}
}
else
{
if (_deceptiveMode == 0)
{
// Pumping failed, Regained: $s1
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FAILED_TO_DO_ANYTHING_WITH_THE_FISH_AND_IT_REGAINS_S1_HP);
sm.addInt(dmg);
_fisher.sendPacket(sm);
_goodUse = 2;
changeHp(-dmg, pen);
}
else
{
// Pumping is successful. Damage: $s1
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_PUMPING_IS_SUCCESSFUL_CAUSING_S1_DAMAGE);
sm.addInt(dmg);
_fisher.sendPacket(sm);
if (pen > 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_MASTERY_PENALTY_S1);
sm.addInt(pen);
_fisher.sendPacket(sm);
}
_goodUse = 1;
changeHp(dmg, pen);
}
}
}
}

View File

@@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.model.fishing;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* Class for the Fishing Monsters object.
* @author nonom
*/
public class L2FishingMonster
{
private final int _userMinLevel;
private final int _userMaxLevel;
private final int _fishingMonsterId;
private final int _probability;
public L2FishingMonster(StatsSet set)
{
_userMinLevel = set.getInt("userMinLevel");
_userMaxLevel = set.getInt("userMaxLevel");
_fishingMonsterId = set.getInt("fishingMonsterId");
_probability = set.getInt("probability");
}
/**
* @return the minimum user level.
*/
public int getUserMinLevel()
{
return _userMinLevel;
}
/**
* @return the maximum user level.
*/
public int getUserMaxLevel()
{
return _userMaxLevel;
}
/**
* @return the fishing monster Id.
*/
public int getFishingMonsterId()
{
return _fishingMonsterId;
}
/**
* @return the probability.
*/
public int getProbability()
{
return _probability;
}
}

View File

@@ -0,0 +1,81 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.model.fishing;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* Class for the Fishing Rod object.
* @author nonom
*/
public class L2FishingRod
{
private final int _fishingRodId;
private final int _fishingRodItemId;
private final int _fishingRodLevel;
private final String _fishingRodName;
private final double _fishingRodDamage;
public L2FishingRod(StatsSet set)
{
_fishingRodId = set.getInt("fishingRodId");
_fishingRodItemId = set.getInt("fishingRodItemId");
_fishingRodLevel = set.getInt("fishingRodLevel");
_fishingRodName = set.getString("fishingRodName");
_fishingRodDamage = set.getDouble("fishingRodDamage");
}
/**
* @return the fishing rod Id.
*/
public int getFishingRodId()
{
return _fishingRodId;
}
/**
* @return the fishing rod Item Id.
*/
public int getFishingRodItemId()
{
return _fishingRodItemId;
}
/**
* @return the fishing rod Level.
*/
public int getFishingRodLevel()
{
return _fishingRodLevel;
}
/**
* @return the fishing rod Item Name.
*/
public String getFishingRodItemName()
{
return _fishingRodName;
}
/**
* @return the fishing rod Damage.
*/
public double getFishingRodDamage()
{
return _fishingRodDamage;
}
}