
I want to activate VITALITY in l2jserver 6300 using this code(script) - (my english is too little !

doing this manualy is too long ! Are You know about programm to do it in automaticaly way?Index: java/config/General.properties
===================================================================
--- java/config/General.properties (revision 2739)
+++ java/config/General.properties (working copy)
@@ -543,4 +543,12 @@
CustomDroplistTable = false
# Option to store alternative merchant data on a custom table.
-CustomMerchantTables = false
\ No newline at end of file
+CustomMerchantTables = false
+
+#============================================================#
+# Vitality System #
+#============================================================#
+
+# Turns Vitality support on. This feature is for testing!
+EnableVitality = false
+RecoverVitalityOnReconnect = true
\ No newline at end of file
Index: java/config/rates.properties
===================================================================
--- java/config/rates.properties (revision 2739)
+++ java/config/rates.properties (working copy)
@@ -54,3 +54,19 @@
RateSuperiorHerbs = 0.8
# Herb of Warrior, Herb of Mystic, Herb of Recovery
RateSpecialHerbs = 0.2
+
+
+# =================================================================
+# VITALITY RATES
+# =================================================================
+# Vitality Replenishing Herb
+RateVitalityHerbs = 5.
+# Vitality Increase/ Decrease Rates
+RateVitalityLevel1 = 1.5
+RateVitalityLevel2 = 2.
+RateVitalityLevel3 = 2.5
+RateVitalityLevel4 = 3.
+RateRecoveryPeaceZone = 0.25
+RateRecoveryOnReconnect = 1.
+RateVitalityLost = 1.
+RateVitalityGain = 1.
\ No newline at end of file
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (revision 2739)
+++ java/net/sf/l2j/Config.java (working copy)
@@ -499,6 +499,9 @@
public static boolean CUSTOM_TELEPORT_TABLE;
public static boolean CUSTOM_DROPLIST_TABLE;
public static boolean CUSTOM_MERCHANT_TABLES;
+ public static boolean ENABLE_VITALITY;
+ public static boolean RECOVER_VITALITY_ON_RECONNECT;
+
/** ************************************************** **/
/** General Settings -End **/
@@ -674,6 +677,17 @@
public static float RATE_DROP_SUPERIOR_HERBS;
/** Rate Common herbs */
public static float RATE_DROP_SPECIAL_HERBS;
+ /** Rate Vitality herb */
+ public static float RATE_DROP_VITALITY_HERBS;
+ /** Rate Vitality Decrease/Increase */
+ public static float RATE_VITALITY_LEVEL_1;
+ public static float RATE_VITALITY_LEVEL_2;
+ public static float RATE_VITALITY_LEVEL_3;
+ public static float RATE_VITALITY_LEVEL_4;
+ public static float RATE_RECOVERY_VITALITY_PEACE_ZONE;
+ public static float RATE_VITALITY_LOST;
+ public static float RATE_VITALITY_GAIN;
+ public static float RATE_RECOVERY_ON_RECONNECT;
/** Limit for player drop */
public static int PLAYER_DROP_LIMIT;
/** Rate for drop */
@@ -1640,6 +1654,9 @@
CUSTOM_TELEPORT_TABLE = Boolean.valueOf(General.getProperty("CustomTeleportTable", "false"));
CUSTOM_DROPLIST_TABLE = Boolean.valueOf(General.getProperty("CustomDroplistTable", "false"));
CUSTOM_MERCHANT_TABLES = Boolean.valueOf(General.getProperty("CustomMerchantTables", "false"));
+ ENABLE_VITALITY = Boolean.parseBoolean(General.getProperty("EnableVitality", "true"));
+ RECOVER_VITALITY_ON_RECONNECT = Boolean.parseBoolean(General.getProperty("RecoverVitalityOnReconnect", "true"));
+
}
catch (Exception e)
{
@@ -1715,7 +1732,17 @@
RATE_DROP_GREATER_HERBS = Float.parseFloat(ratesSettings.getProperty("RateGreaterHerbs", "4."));
RATE_DROP_SUPERIOR_HERBS = Float.parseFloat(ratesSettings.getProperty("RateSuperiorHerbs", "0.8"))*10;
RATE_DROP_SPECIAL_HERBS = Float.parseFloat(ratesSettings.getProperty("RateSpecialHerbs", "0.2"))*10;
-
+ RATE_DROP_VITALITY_HERBS = Float.parseFloat(ratesSettings.getProperty("RateVitalityHerbs", "5."));
+
+ RATE_VITALITY_LEVEL_1 = Float.parseFloat(ratesSettings.getProperty("RateVitalityLevel1", "1.5"));
+ RATE_VITALITY_LEVEL_2 = Float.parseFloat(ratesSettings.getProperty("RateVitalityLevel2", "2."));
+ RATE_VITALITY_LEVEL_3 = Float.parseFloat(ratesSettings.getProperty("RateVitalityLevel3", "2.5"));
+ RATE_VITALITY_LEVEL_4 = Float.parseFloat(ratesSettings.getProperty("RateVitalityLevel4", "3."));
+ RATE_RECOVERY_VITALITY_PEACE_ZONE = Float.parseFloat(ratesSettings.getProperty("RateRecoveryPeaceZone", "0.25"));
+ RATE_RECOVERY_ON_RECONNECT = Float.parseFloat(ratesSettings.getProperty("RateRecoveryOnReconnect", "1."));
+ RATE_VITALITY_LOST = Float.parseFloat(ratesSettings.getProperty("RateVitalityLost", "1."));
+ RATE_VITALITY_GAIN = Float.parseFloat(ratesSettings.getProperty("RateVitalityGain", "1."));
+
PLAYER_DROP_LIMIT = Integer.parseInt(ratesSettings.getProperty("PlayerDropLimit", "3"));
PLAYER_RATE_DROP = Integer.parseInt(ratesSettings.getProperty("PlayerRateDrop", "5"));
PLAYER_RATE_DROP_ITEM = Integer.parseInt(ratesSettings.getProperty("PlayerRateDropItem", "70"));
Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 2739)
+++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
@@ -106,6 +106,7 @@
registerAdminCommandHandler(new AdminTvTEvent());
registerAdminCommandHandler(new AdminUnblockIp());
registerAdminCommandHandler(new AdminZone());
+ registerAdminCommandHandler(new AdminVitality());
_log.config("AdminCommandHandler: Loaded " + _datatable.size() + " handlers.");
}
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminVitality.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminVitality.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminVitality.java (revision 0)
@@ -0,0 +1,147 @@
+/*
+ * 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 net.sf.l2j.gameserver.handler.admincommandhandlers;
+
+import java.util.StringTokenizer;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Psychokiller1888
+ */
+public class AdminVitality implements IAdminCommandHandler
+{
+ private static int level = 0;
+ private static double vitality = 0.0;
+
+ private static final String[] ADMIN_COMMANDS =
+ {
+ "admin_set_vitality",
+ "admin_set_vitality_level",
+ "admin_full_vitality",
+ "admin_empty_vitality",
+ "admin_get_vitality"
+ };
+
+ public boolean useAdminCommand(String command, L2PcInstance activeChar)
+ {
+ if (activeChar == null)
+ return false;
+
+ if (!Config.ENABLE_VITALITY)
+ {
+ activeChar.sendMessage("Vitality is not enabled on the server!");
+ return false;
+ }
+
+ L2PcInstance target;
+ target = (L2PcInstance) activeChar.getTarget();
+
+ StringTokenizer st = new StringTokenizer(command, " ");
+ String cmd = st.nextToken();
+
+ if (activeChar.getTarget() instanceof L2PcInstance)
+ {
+ if (cmd.equals("admin_set_vitality"))
+ {
+ try
+ {
+ vitality = Double.parseDouble(st.nextToken());
+ }
+ catch (Exception e)
+ {
+ activeChar.sendMessage("Incorrect vitality");
+ }
+
+ target.setVitalityPoints(vitality, true);
+ target.updateVitalityLevel(false);
+ target.sendMessage("Admin set your Vitality points to " + vitality);
+ }
+ else if (cmd.equals("admin_set_vitality_level"))
+ {
+ try
+ {
+ level = Integer.parseInt(st.nextToken());
+ }
+ catch (Exception e)
+ {
+ activeChar.sendMessage("Incorrect vitality level (0-4)");
+ }
+
+ if (level >= 0 && level <= 4)
+ {
+ switch (level)
+ {
+ case 0:
+ vitality = 1.0;
+ break;
+ case 1:
+ vitality = 3601.0;
+ break;
+ case 2:
+ vitality = 27001.0;
+ break;
+ case 3:
+ vitality = 219001.0;
+ break;
+ case 4:
+ vitality = 273001.0;
+ break;
+ }
+ target.setVitalityPoints(vitality, true);
+ target.updateVitalityLevel(false);
+ target.sendMessage("Admin set your Vitality level to " + level);
+ }
+ else
+ activeChar.sendMessage("Incorrect vitality level (0-4)");
+ }
+ else if (cmd.equals("admin_full_vitality"))
+ {
+ target.setVitalityPoints(300000.0, true);
+ target.updateVitalityLevel(false);
+ target.sendMessage("Admin completly recharged your Vitality");
+ }
+ else if (cmd.equals("admin_empty_vitality"))
+ {
+ target.setVitalityPoints(1, true);
+ target.updateVitalityLevel(false);
+ target.sendMessage("Admin completly emptied your Vitality");
+ }
+ else if (cmd.equals("admin_get_vitality"))
+ {
+ int playerVitalityLevel = target.getVitalityLevel();
+ double playerVitalityPoints = target.getVitalityPoints();
+
+ target.updateVitalityLevel(false);
+
+ activeChar.sendMessage("Player vitality level: " + playerVitalityLevel);
+ activeChar.sendMessage("Player vitality points: " + playerVitalityPoints);
+ }
+ return true;
+ }
+ else
+ {
+ activeChar.sendMessage("Target not found or not a player");
+ return false;
+ }
+ }
+
+ public String[] getAdminCommandList()
+ {
+ return ADMIN_COMMANDS;
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/handler/itemhandlers/Potions.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/itemhandlers/Potions.java (revision 2739)
+++ java/net/sf/l2j/gameserver/handler/itemhandlers/Potions.java (working copy)
@@ -62,7 +62,9 @@
// Juices
10260, 10261, 10262, 10263, 10264, 10265, 10266, 10267, 10268, 10269, 10270,
// CT2 herbs
- 10655, 10656, 10657
+ 10655, 10656, 10657,
+ // CT2.2 Vitality Herb
+ 13028
};
/**
@@ -329,6 +331,9 @@
case 10657:
res = usePotion(playable, 2513, 1);
break;
+ case 13028:
+ res = usePotion(playable, 2580, 1);
+ break;
// FISHERMAN POTIONS
case 8193: // Fisherman's Potion - Green
Index: java/net/sf/l2j/gameserver/model/L2Attackable.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Attackable.java (revision 2739)
+++ java/net/sf/l2j/gameserver/model/L2Attackable.java (working copy)
@@ -666,8 +666,18 @@
}
}
}
- attacker.addExpAndSp(addexp,addsp);
- }
+ if (Config.ENABLE_VITALITY)
+ {
+ if (attacker instanceof L2PcInstance)
+ {
+ ((L2PcInstance)attacker).addVitExpAndSp(addexp, addsp, this);
+ ((L2PcInstance)attacker).calculateVitalityPointsAddRed(this, reward._dmg, 1, 1f);
+ }
+ else
+ attacker.addExpAndSp(addexp, addsp);
+ }
+ else
+ attacker.addExpAndSp(addexp, addsp); }
}
}
else
@@ -781,7 +791,7 @@
}
// Distribute Experience and SP rewards to L2PcInstance Party members in the known area of the last attacker
- if (partyDmg > 0) attackerParty.distributeXpAndSp(exp, sp, rewardedMembers, partyLvl, this);
+ if (partyDmg > 0) attackerParty.distributeXpAndSp(exp, sp, rewardedMembers, partyLvl, this, partyDmg);
}
}
}
@@ -1546,6 +1556,19 @@
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS) player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
else dropItem(player, item);
}
+ // Vitality Herb
+ if (Config.ENABLE_VITALITY)
+ {
+ random = Rnd.get(100);
+ if (random < Config.RATE_DROP_VITALITY_HERBS)
+ {
+ RewardItem item = new RewardItem(13028, 1); // Vitality Replenishing Herb
+ if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
+ player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
+ else
+ dropItem(player, item);
+ }
+ }
}
}
Index: java/net/sf/l2j/gameserver/model/L2Party.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Party.java (revision 2739)
+++ java/net/sf/l2j/gameserver/model/L2Party.java (working copy)
@@ -650,7 +650,7 @@
* @param rewardedMembers The list of L2PcInstance to reward
*
*/
- public void distributeXpAndSp(long xpReward, int spReward, List<L2PlayableInstance> rewardedMembers, int topLvl, L2NpcInstance target)
+ public void distributeXpAndSp(long xpReward, int spReward, List<L2PlayableInstance> rewardedMembers, int topLvl, L2NpcInstance target, int partyDmg)
{
L2SummonInstance summon = null;
List<L2PlayableInstance> validMembers = getValidMembers(rewardedMembers, topLvl);
@@ -712,8 +712,18 @@
((L2PcInstance)member).absorbSoul(skill,target);
}
}
- member.addExpAndSp(addexp,addsp);
- }
+ if (Config.ENABLE_VITALITY)
+ {
+ if (member instanceof L2PcInstance)
+ {
+ ((L2PcInstance) member).addVitExpAndSp(addexp, addsp, target);
+ ((L2PcInstance) member).calculateVitalityPointsAddRed(target, partyDmg, rewardedMembers.size(), Config.RATE_PARTY_XP);
+ }
+ else
+ member.addExpAndSp(addexp,addsp);
+ }
+ else
+ member.addExpAndSp(addexp,addsp); }
}
else
{
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 2739)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -23,6 +23,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
@@ -201,6 +202,7 @@
import net.sf.l2j.gameserver.skills.Stats;
import net.sf.l2j.gameserver.skills.l2skills.L2SkillSiegeFlag;
import net.sf.l2j.gameserver.templates.chars.L2PcTemplate;
+import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.gameserver.templates.item.L2Armor;
import net.sf.l2j.gameserver.templates.item.L2ArmorType;
import net.sf.l2j.gameserver.templates.item.L2EtcItemType;
@@ -237,8 +239,8 @@
// Character Character SQL String Definitions:
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE charId=?";
- private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE charId=?";
+ private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,vitality_points=? WHERE charId=?";
+ private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,vitality_points FROM characters WHERE charId=?";
// Character Subclass SQL String Definitions:
private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE charId=? ORDER BY class_index ASC";
@@ -401,9 +403,6 @@
public boolean _exploring = false;
- /** Vitality Level of this L2PcInstance */
- private int _vitalityLevel = 5;
-
private boolean _inCrystallize;
private boolean _inCraftMode;
@@ -444,6 +443,11 @@
/** List with the recommendations that I've give */
private List<Integer> _recomChars = new FastList<Integer>();
+ /** Vitality System */
+ private double _vitalityPoints = 1.0;
+ private int _vitalityLevel = 0;
+ private Future<?> _VitalityResTask;
+
/** The random number of the L2PcInstance */
//private static final Random _rnd = new Random();
@@ -678,6 +682,29 @@
private boolean _isRidingStrider = false;
private boolean _isFlyingWyvern = false;
+ static class VitalityResTask implements Runnable
+ {
+ private L2PcInstance _activechar;
+ VitalityResTask(L2PcInstance activeChar)
+ {
+ this._activechar = activeChar;
+ }
+ public void run()
+ {
+ try
+ {
+ if ((this._activechar.isInsideZone((byte) 1)) && (this._activechar.getVitalityPoints() < 300000.0))
+ {
+ double incPointsInPeaceZone = Config.RATE_RECOVERY_VITALITY_PEACE_ZONE;
+ this._activechar.incVitalityPointsBy(incPointsInPeaceZone, true);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
/** Herbs Task Time **/
private int _herbstask = 0;
/** Task for Herbs */
@@ -982,6 +1009,9 @@
if (!Config.WAREHOUSE_CACHE)
getWarehouse();
getFreight().restore();
+
+ if (Config.ENABLE_VITALITY)
+ startVitalityTask();
}
private L2PcInstance(int objectId)
@@ -5547,6 +5577,8 @@
stopPvpRegTask();
stopJailTask(true);
stopSoulTask();
+ if (Config.ENABLE_VITALITY)
+ stopVitalityResTask();
}
/**
@@ -6627,6 +6659,7 @@
player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));
player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
+ player.setVitalityPoints(rset.getDouble("vitality_points"), false);
// Add the L2PcInstance object in _allObjects
//L2World.getInstance().storeObject(player);
@@ -6987,8 +7020,8 @@
statement.setLong(47, getClanCreateExpiryTime());
statement.setString(48, getName());
statement.setLong(49, getDeathPenaltyBuffLevel());
- statement.setInt(50, getObjectId());
-
+ statement.setDouble(50, getVitalityPoints());
+ statement.setInt(51, getObjectId());
statement.execute();
statement.close();
}
@@ -10168,7 +10201,46 @@
}
@Override
- public void addExpAndSp(long addToExp, int addToSp) { getStat().addExpAndSp(addToExp, addToSp); }
+ public void addExpAndSp(long addToExp, int addToSp)
+ {
+ getStat().addExpAndSp(addToExp, addToSp);
+ }
+
+ public void addVitExpAndSp(long addToExp, int addToSp, L2NpcInstance target)
+ {
+ if (target == null)
+ return;
+
+ long addToExpVit = addToExp;
+ int addToSpVit = addToSp;
+
+ if (!target.isRaid())
+ {
+ switch (getVitalityLevel())
+ {
+ case 0:
+ break;
+ case 1:
+ addToExpVit = (long)(addToExpVit * Config.RATE_VITALITY_LEVEL_1);
+ addToSpVit = (int)(addToSpVit * Config.RATE_VITALITY_LEVEL_1);
+ break;
+ case 2:
+ addToExpVit = (long)(addToExpVit * Config.RATE_VITALITY_LEVEL_2);
+ addToSpVit = (int)(addToSpVit * Config.RATE_VITALITY_LEVEL_2);
+ break;
+ case 3:
+ addToExpVit = (long)(addToExpVit * Config.RATE_VITALITY_LEVEL_3);
+ addToSpVit = (int)(addToSpVit * Config.RATE_VITALITY_LEVEL_3);
+ break;
+ case 4:
+ addToExpVit = (long)(addToExpVit * Config.RATE_VITALITY_LEVEL_4);
+ addToSpVit = (int)(addToSpVit * Config.RATE_VITALITY_LEVEL_4);
+ break;
+ }
+ }
+ getStat().addExpAndSp(addToExpVit, addToSpVit);
+ }
+
public void removeExpAndSp(long removeExp, int removeSp) { getStat().removeExpAndSp(removeExp, removeSp); }
@Override
public void reduceCurrentHp(double i, L2Character attacker)
@@ -11698,28 +11770,192 @@
return _agathionId;
}
- /**
- * Returns the VL <BR><BR>
- * @return
- */
- public int getVitalityLevel()
- {
- return _vitalityLevel;
- }
-
- /**
- * Sets VL of this L2PcInstance<BR><BR>
- * @param level
- */
- public void setVitalityLevel(int level)
- {
- if (level > 5)
- level = 5;
- else if (level < 0)
- level = 0;
-
- _vitalityLevel = level;
- }
+ private void startVitalityTask()
+ {
+ stopVitalityResTask();
+ this._VitalityResTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new VitalityResTask(this), 1000, 1000);
+ }
+
+ private void stopVitalityResTask()
+ {
+ if (this._VitalityResTask != null)
+ {
+ this._VitalityResTask.cancel(true);
+ this._VitalityResTask = null;
+ }
+ }
+
+ public synchronized void setVitalityPoints(double val, boolean sendMessage)
+ {
+ if (val >= 300000.0)
+ this._vitalityPoints = 300000.0;
+ else if (val <= 1D)
+ this._vitalityPoints = 1.0;
+ else
+ this._vitalityPoints = val;
+
+ updateVitalityLevel(sendMessage);
+ }
+
+ public double getVitalityPoints()
+ {
+ return this._vitalityPoints;
+ }
+
+ public void setVitalityLevel(int val, boolean sendMessage)
+ {
+ int oldVitalityLVL = getVitalityLevel();
+ this._vitalityLevel = val;
+ int curVitalityLVL = getVitalityLevel();
+ sendPacket(new UserInfo(this));
+
+ if (sendMessage)
+ {
+ if (oldVitalityLVL < curVitalityLVL)
+ sendPacket(new SystemMessage(SystemMessageId.VITALITY_HAS_INCREASED));
+ if (oldVitalityLVL > curVitalityLVL)
+ sendPacket(new SystemMessage(SystemMessageId.VITALITY_HAS_DECREASED));
+ if (curVitalityLVL == 4)
+ sendPacket(new SystemMessage(SystemMessageId.VITALITY_IS_AT_MAXIMUM));
+ if (curVitalityLVL == 0)
+ sendPacket(new SystemMessage(SystemMessageId.VITALITY_IS_FULLY_EXHAUSTED));
+ }
+ }
+
+ public int getVitalityLevel()
+ {
+ return this._vitalityLevel;
+ }
+
+ public void updateVitalityLevel(boolean sendMessage)
+ {
+ int curVitalityLVL = getVitalityLevel();
+ double curVitalityPoints = getVitalityPoints();
+
+ if ((curVitalityPoints >= 273000.0) && (curVitalityPoints <= 300000.0) && (curVitalityLVL < 4))
+ setVitalityLevel(4, sendMessage);
+ if ((curVitalityPoints > 219000.0) && (curVitalityPoints <= 273000.0) && (((curVitalityLVL > 3) || (curVitalityLVL < 3))))
+ setVitalityLevel(3, sendMessage);
+ if ((curVitalityPoints > 27000.0) && (curVitalityPoints <= 219000.0) && (((curVitalityLVL > 2) || (curVitalityLVL < 2))))
+ setVitalityLevel(2, sendMessage);
+ if ((curVitalityPoints > 3600.0) && (curVitalityPoints <= 27000.0) && (((curVitalityLVL > 1) || (curVitalityLVL < 1))))
+ setVitalityLevel(1, sendMessage);
+ if ((curVitalityPoints <= 3600.0) && (curVitalityLVL > 0))
+ setVitalityLevel(0, sendMessage);
+ }
+
+ public synchronized void incVitalityPointsBy(double val, boolean sendMessage)
+ {
+ double curVitalPoints = this._vitalityPoints;
+
+ if (curVitalPoints + val >= 300000.0)
+ this._vitalityPoints = 300000.0;
+ else
+ this._vitalityPoints += val;
+
+ updateVitalityLevel(sendMessage);
+ }
+
+ public synchronized void decVitalityPointsBy(double val, boolean sendMessage)
+ {
+ double curVitalPoints = this._vitalityPoints;
+
+ if (curVitalPoints - val <= 1D)
+ this._vitalityPoints = 1;
+ else
+ this._vitalityPoints -= val;
+
+ updateVitalityLevel(sendMessage);
+ }
+
+ public void calculateVitalityPointsAddRed(L2NpcInstance target, int Dmg, int partyMembers, float partyExpRate)
+ {
+ double calculatedVitPointLos;
+ if (target == null)
+ return;
+
+ L2NpcTemplate template = target.getTemplate();
+ int targetExp = template.rewardExp;
+ int playerLVL = getLevel();
+ int targetLVL = target.getLevel();
+ int lvlDiff = targetLVL - playerLVL;
+ long playerExpDiff = net.sf.l2j.gameserver.model.base.Experience.LEVEL[(playerLVL + 1)] - net.sf.l2j.gameserver.model.base.Experience.LEVEL[playerLVL];
+ double hpRate = target.getStat().calcStat(Stats.MAX_HP, 1D, this, null);
+ double baseVitLostGet = 1000.0;
+ double basePartyExpRate = 1.0;
+ double lvlDiffRate = 1.0;
+ double dmgRate = 1.0;
+
+ if (targetExp == 0)
+ return;
+ if (playerLVL < 10)
+ return;
+ if (Dmg >= target.getMaxHp())
+ Dmg = target.getMaxHp();
+ else if ((Dmg < target.getMaxHp()) && (Dmg != 0))
+ dmgRate = 100.0 / target.getMaxHp() * Dmg / 100.0;
+ if (hpRate > 1D)
+ hpRate = 1D + hpRate / 10.0;
+ if (partyMembers < 2)
+ partyMembers = 1;
+ if ((partyExpRate > 1F) && (partyMembers > 1))
+ basePartyExpRate += partyExpRate / 10.0;
+
+ double preCalc = playerLVL * playerLVL * targetExp * hpRate * basePartyExpRate / playerExpDiff * baseVitLostGet;
+ boolean isVitalityBuffed = false;
+
+ L2Effect[] effects = getAllEffects();
+ for (L2Effect e : effects)
+ {
+ if (e.getSkill().getId() == 2580)
+ isVitalityBuffed = true;
+ }
+
+ if (target.isRaid() || isVitalityBuffed)
+ {
+ if (lvlDiff > 0)
+ lvlDiffRate += lvlDiff / 10.0;
+ else if (lvlDiff < 0)
+ lvlDiffRate -= Math.abs(lvlDiff) / 10.0;
+ if (lvlDiffRate > 2.0)
+ lvlDiffRate = 2.0;
+ if (lvlDiffRate <= 0)
+ lvlDiffRate = 0.10000000000000001;
+
+ calculatedVitPointLos = (preCalc * lvlDiffRate * dmgRate / partyMembers / 2.0) * Config.RATE_VITALITY_GAIN;
+ if (calculatedVitPointLos > 0)
+ sendPacket(new SystemMessage(SystemMessageId.GAINED_VITALITY_POINTS));
+ incVitalityPointsBy(calculatedVitPointLos, true);
+ }
+ else
+ {
+ if (lvlDiff > 0)
+ lvlDiffRate -= lvlDiff / 10;
+ else if (lvlDiff < 0)
+ lvlDiffRate += Math.abs(lvlDiff) / 10;
+ if (lvlDiffRate <= 0)
+ lvlDiffRate = 0.10000000000000001;
+ if (lvlDiffRate > 2.0)
+ lvlDiffRate = 2.0;
+
+ calculatedVitPointLos = (preCalc * lvlDiffRate * dmgRate / partyMembers) * Config.RATE_VITALITY_LOST;
+ decVitalityPointsBy(calculatedVitPointLos, true);
+ }
+ }
+
+ public void restoreVitality()
+ {
+ long lastAccessTime = getLastAccess();
+ long curTime = System.currentTimeMillis();
+ double vitalityPointsRest = getVitalityPoints();
+ double vitalityPointsToAdd = ((curTime - lastAccessTime) / 1000.0) * Config.RATE_RECOVERY_ON_RECONNECT;
+
+ if (vitalityPointsToAdd <= 0)
+ vitalityPointsToAdd = 0;
+ if (Config.RECOVER_VITALITY_ON_RECONNECT)
+ setVitalityPoints(vitalityPointsRest + vitalityPointsToAdd, false);
+ }
+
/*
* Function for skill summon friend or Gate Chant.
Index: java/net/sf/l2j/gameserver/network/SystemMessageId.java
===================================================================
--- java/net/sf/l2j/gameserver/network/SystemMessageId.java (revision 2739)
+++ java/net/sf/l2j/gameserver/network/SystemMessageId.java (working copy)
@@ -13633,6 +13633,12 @@
*/
SKILL_NOT_FOR_SUBCLASS(2273),
+ /**
+ * ID: 2296<br>
+ * Message: You have gained Vitality points.
+ */
+ GAINED_VITALITY_POINTS(2296),
+
/**
* ID: 2303<br>
* Message: There are $s2 second(s) remaining in $s1's re-use time.
@@ -13651,6 +13657,30 @@
*/
S2_HOURS_S3_MINUTES_S4_SECONDS_REMAINING_FOR_REUSE_S1(2305),
+ /**
+ * ID: 2314<br>
+ * Message: You have gained Vitality points.
+ */
+ VITALITY_IS_AT_MAXIMUM(2314),
+
+ /**
+ * ID: 2315<br>
+ * Message: You have gained Vitality points.
+ */
+ VITALITY_HAS_INCREASED(2315),
+
+ /**
+ * ID: 2316<br>
+ * Message: You have gained Vitality points.
+ */
+ VITALITY_HAS_DECREASED(2316),
+
+ /**
+ * ID: 2317<br>
+ * Message: You have gained Vitality points.
+ */
+ VITALITY_IS_FULLY_EXHAUSTED(2317),
+
/**
* ID: 2326<br>
* Message: You have acquired 50 Clan's Fame Points..
Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (revision 2739)
+++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (working copy)
@@ -133,7 +133,9 @@
newChar.setCurrentHp(template.baseHpMax);
newChar.setCurrentCp(template.baseCpMax);
newChar.setCurrentMp(template.baseMpMax);
- //newChar.setMaxLoad(template.baseLoad);
+
+ // Vitality System
+ newChar.setVitalityPoints(300000.0D, false);
// send acknowledgement
CharCreateOk cco = new CharCreateOk();
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 2739)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
@@ -189,7 +189,12 @@
}
setPledgeClass(activeChar);
-
+
+ if (Config.ENABLE_VITALITY)
+ {
+ activeChar.restoreVitality();
+ }
+
activeChar.sendPacket(new UserInfo(activeChar));
// Send Macro List
Please,write MANUAL step-by-step what to do!
Thanks...