Addition of WorldChat and DamageByAttack effect handlers.

Adapted from: L2jUnity free files.
This commit is contained in:
MobiusDev
2017-12-07 22:57:14 +00:00
parent b04890d93c
commit d4187ff765
110 changed files with 870 additions and 345 deletions

View File

@@ -98,6 +98,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("CrystalGradeModify", CrystalGradeModify::new);
EffectHandler.getInstance().registerHandler("CubicMastery", CubicMastery::new);
EffectHandler.getInstance().registerHandler("DamageBlock", DamageBlock::new);
EffectHandler.getInstance().registerHandler("DamageByAttack", DamageByAttack::new);
EffectHandler.getInstance().registerHandler("DamageShield", DamageShield::new);
EffectHandler.getInstance().registerHandler("DamageShieldResist", DamageShieldResist::new);
EffectHandler.getInstance().registerHandler("DamOverTime", DamOverTime::new);
@@ -360,6 +361,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("VitalityPointUp", VitalityPointUp::new);
EffectHandler.getInstance().registerHandler("WeightLimit", WeightLimit::new);
EffectHandler.getInstance().registerHandler("WeightPenalty", WeightPenalty::new);
EffectHandler.getInstance().registerHandler("WorldChatPoints", WorldChatPoints::new);
LOGGER.info(EffectMasterHandler.class.getSimpleName() + ": Loaded " + EffectHandler.getInstance().size() + " effect handlers.");
}
}

View File

@@ -333,7 +333,7 @@ public class AdminAdmin implements IAdminCommandHandler
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
break;
}
activeChar.sendMessage(targetPlayer.getName() + ": has " + targetPlayer.getWorldChatPoints() + " world chat points");
activeChar.sendMessage(targetPlayer.getName() + ": has used world chat " + targetPlayer.getWorldChatUsed() + " times out of maximum " + targetPlayer.getWorldChatPoints() + " times.");
break;
}
case "set":
@@ -354,19 +354,19 @@ public class AdminAdmin implements IAdminCommandHandler
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <times used>");
break;
}
final String valueToken = st.nextToken();
if (!Util.isDigit(valueToken))
{
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <times used>");
break;
}
activeChar.sendMessage(targetPlayer.getName() + ": points changed from " + targetPlayer.getWorldChatPoints() + " to " + valueToken);
targetPlayer.setWorldChatPoints(Integer.parseInt(valueToken));
activeChar.sendMessage(targetPlayer.getName() + ": times used changed from " + targetPlayer.getWorldChatPoints() + " to " + valueToken);
targetPlayer.setWorldChatUsed(Integer.parseInt(valueToken));
if (Config.ENABLE_WORLD_CHAT)
{
targetPlayer.sendPacket(new ExWorldChatCnt(targetPlayer));

View File

@@ -74,7 +74,7 @@ public final class ChatWorld implements IChatHandler
activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
return;
}
else if (activeChar.getWorldChatPoints() < 1)
else if (activeChar.getWorldChatUsed() >= activeChar.getWorldChatPoints())
{
activeChar.sendPacket(SystemMessageId.YOU_HAVE_SPENT_YOUR_WORLD_CHAT_QUOTA_FOR_THE_DAY_A_NEW_DAY_STARTS_EVERY_DAY_AT_18_30);
}
@@ -111,7 +111,7 @@ public final class ChatWorld implements IChatHandler
L2World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
}
activeChar.setWorldChatPoints(activeChar.getWorldChatPoints() - 1);
activeChar.setWorldChatUsed(activeChar.getWorldChatUsed() + 1);
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
if (Config.WORLD_CHAT_INTERVAL.getSeconds() > 0)
{

View File

@@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Formulas;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* Backstab effect implementation.
@@ -89,12 +88,6 @@ public final class Backstab extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, true);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, true, true, false);
// Manage attack or cast break of the target (calculating rate, sending message...)
if (!effected.isRaid() && Formulas.calcAtkBreak(effected, damage))

View File

@@ -0,0 +1,63 @@
/*
* 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 handlers.effecthandlers;
import com.l2jmobius.gameserver.enums.DamageByAttackType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* An effect that changes damage taken from an attack.<br>
* The retail implementation seems to be altering whatever damage is taken after the attack has been done and not when attack is being done. <br>
* Exceptions for this effect appears to be DOT effects and terrain damage, they are unaffected by this stat.<br>
* As for example in retail this effect does reduce reflected damage taken (because it is received damage), as well as it does not decrease reflected damage done,<br>
* because reflected damage is being calculated with the original attack damage and not this altered one.<br>
* Multiple values of this effect add-up to each other rather than multiplying with each other. Be careful, there were cases in retail where damage is deacreased to 0.
* @author Nik
*/
public class DamageByAttack extends AbstractEffect
{
private final double _value;
private final DamageByAttackType _type;
public DamageByAttack(StatsSet params)
{
_value = params.getDouble("amount");
_type = params.getEnum("type", DamageByAttackType.class, DamageByAttackType.NONE);
}
@Override
public void pump(L2Character target, Skill skill)
{
switch (_type)
{
case PK:
{
target.getStat().mergeAdd(Stats.PVP_DAMAGE_TAKEN, _value);
break;
}
case ENEMY_ALL:
{
target.getStat().mergeAdd(Stats.PVE_DAMAGE_TAKEN, _value);
break;
}
}
}
}

View File

@@ -165,11 +165,6 @@ public final class EnergyAttack extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(attacker, effected, skill, critical);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, critical, false);
// attacker.sendDamageMessage(effected, skill, (int) damage, critical, false);
}

View File

@@ -30,7 +30,6 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalType;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Formulas;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* Fatal Blow effect implementation.
@@ -121,12 +120,6 @@ public final class FatalBlow extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, true);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, true, false);
// Manage attack or cast break of the target (calculating rate, sending message...)

View File

@@ -174,11 +174,7 @@ public final class PhysicalAttack extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, critical);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, critical, false);
// effector.sendDamageMessage(effected, skill, (int) damage, critical, false);
}

View File

@@ -137,11 +137,6 @@ public final class PhysicalAttackHpLink extends AbstractEffect
// Check if damage should be reflected.
Formulas.calcCounterAttack(effector, effected, skill, critical);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, critical, false);
// effector.sendDamageMessage(effected, skill, (int) damage, critical, false);
}

View File

@@ -147,12 +147,6 @@ public final class PhysicalAttackSaveHp extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, critical);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
final double minHp = (effected.getMaxHp() * _saveHp) / 100;
if ((effected.getCurrentHp() - damage) < minHp)

View File

@@ -168,11 +168,6 @@ public final class PhysicalAttackWeaponBonus extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, critical);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, critical, false);
// effector.sendDamageMessage(effected, skill, (int) damage, critical, false);
}

View File

@@ -162,11 +162,6 @@ public final class PhysicalSoulAttack extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, critical);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, critical, false);
// effector.sendDamageMessage(effected, skill, (int) damage, critical, false);
}

View File

@@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Formulas;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* Soul Blow effect implementation.
@@ -94,12 +93,6 @@ public final class SoulBlow extends AbstractEffect
// Check if damage should be reflected
Formulas.calcCounterAttack(effector, effected, skill, true);
final double damageCap = effected.getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
damage = Math.min(damage, damageCap);
}
effected.reduceCurrentHp(damage, effector, skill, false, false, true, false);
// Manage attack or cast break of the target (calculating rate, sending message...)

View File

@@ -0,0 +1,31 @@
/*
* 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 handlers.effecthandlers;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* @author Nik
*/
public class WorldChatPoints extends AbstractStatEffect
{
public WorldChatPoints(StatsSet params)
{
super(params, Stats.WORLD_CHAT_POINTS);
}
}

View File

@@ -67,6 +67,7 @@ CriticalRatePositionBonus: Critical Rate depending on position stat. Ignores the
CrystalGradeModify: Sets your Expertise Grade level. With this effect you can make lv. 40 player (C Grade) to wear S grade.
CubicMastery: Max cubics stat.
DamageBlock: Blocks Hp or Mp damage/heal.
DamageByAttack: An effect that changes damage taken from an attack.
DamageShield: Reflect damage percentage stat.
DamageShieldResist: Reflect damage percentage resist.
DamOverTime: Damage over time effect. Magic Critical results in 10 times amount to me instantly inflicted before the effect is started.
@@ -326,4 +327,5 @@ VitalityExpRate: Sets the vitality exp rate. (l2jmobius)
VitalityPointsRate: Vitality points consume rate.
VitalityPointUp: Increases vitality points.
WeightLimit: Maximum weight stat.
WeightPenalty: Weight penalty level stat.
WeightPenalty: Weight penalty level stat.
WorldChatPoints: Modify world chat points to use per day.

View File

@@ -0,0 +1,26 @@
/*
* 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.enums;
public enum DamageByAttackType
{
NONE,
PK, // Players and summons.
MOB, // Regular monsters.
BOSS, // Boss monsters
ENEMY_ALL; // All NPCs
}

View File

@@ -159,7 +159,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
// Update data for online players.
L2World.getInstance().getPlayers().stream().forEach(player ->
{
player.getVariables().set(PlayerVariables.EXTEND_DROP, "");
player.getVariables().remove(PlayerVariables.EXTEND_DROP);
player.getVariables().storeMe();
});
@@ -198,7 +198,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE character_variables SET val = ? WHERE var = ?"))
{
ps.setInt(1, Config.WORLD_CHAT_POINTS_PER_DAY);
ps.setInt(1, 0);
ps.setString(2, PlayerVariables.WORLD_CHAT_VARIABLE_NAME);
ps.executeUpdate();
}
@@ -210,7 +210,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
// Update data for online players.
L2World.getInstance().getPlayers().stream().forEach(player ->
{
player.setWorldChatPoints(Config.WORLD_CHAT_POINTS_PER_DAY);
player.setWorldChatUsed(0);
player.sendPacket(new ExWorldChatCnt(player));
player.getVariables().storeMe();
});

View File

@@ -4552,6 +4552,25 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
}
final double damageCap = getStat().getValue(Stats.DAMAGE_LIMIT);
if (damageCap > 0)
{
value = Math.min(value, damageCap);
}
// Calculate PvP/PvE damage received. It is a post-attack stat.
if (attacker != null)
{
if (attacker.isPlayable())
{
value *= (100 + getStat().getValue(Stats.PVP_DAMAGE_TAKEN)) / 100;
}
else
{
value *= (100 + getStat().getValue(Stats.PVE_DAMAGE_TAKEN)) / 100;
}
}
if (Config.CHAMPION_ENABLE && isChampion() && (Config.CHAMPION_HP != 0))
{
getStatus().reduceHp(value / Config.CHAMPION_HP, attacker, (skill == null) || !skill.isToggle(), isDOT, false);

View File

@@ -13385,16 +13385,24 @@ public final class L2PcInstance extends L2Playable
*/
public int getWorldChatPoints()
{
return getVariables().getInt(PlayerVariables.WORLD_CHAT_VARIABLE_NAME, 1);
return (int) getStat().getValue(Stats.WORLD_CHAT_POINTS, Config.WORLD_CHAT_POINTS_PER_DAY);
}
/**
* @return The amount of times player has used world chat
*/
public int getWorldChatUsed()
{
return getVariables().getInt(PlayerVariables.WORLD_CHAT_VARIABLE_NAME, 0);
}
/**
* Sets the amount of times player can use world chat
* @param points
* @param timesUsed how many times world chat has been used up until now.
*/
public void setWorldChatPoints(int points)
public void setWorldChatUsed(int timesUsed)
{
getVariables().set(PlayerVariables.WORLD_CHAT_VARIABLE_NAME, points);
getVariables().set(PlayerVariables.WORLD_CHAT_VARIABLE_NAME, timesUsed);
}
public void prohibiteCeremonyOfChaos()

View File

@@ -103,6 +103,10 @@ public enum Stats
PVE_RAID_PHYSICAL_SKILL_DEFENCE("pveRaidPhysSkillsDef"),
PVE_RAID_MAGICAL_SKILL_DEFENCE("pveRaidMagicalDef"),
// FIXED BONUS
PVP_DAMAGE_TAKEN("pvpDamageTaken"),
PVE_DAMAGE_TAKEN("pveDamageTaken"),
// ATTACK & DEFENCE RATES
MAGIC_CRITICAL_DAMAGE("mCritPower"),
PHYSICAL_SKILL_POWER("physicalSkillPower"), // Adding skill power (not multipliers) results in points added directly to final value unmodified by defence, traits, elements, criticals etc.
@@ -268,6 +272,7 @@ public enum Stats
STAT_BONUS_SKILL_CRITICAL("statSkillCritical"),
STAT_BONUS_SPEED("statSpeed"),
SHOTS_BONUS("shotBonus", new ShotsBonusFinalizer()),
WORLD_CHAT_POINTS("worldChatPoints"),
ATTACK_DAMAGE("attackDamage");
static final Logger LOGGER = Logger.getLogger(Stats.class.getName());

View File

@@ -46,7 +46,7 @@ public class PlayerVariables extends AbstractVariables
// Public variable names
public static final String HAIR_ACCESSORY_VARIABLE_NAME = "HAIR_ACCESSORY_ENABLED";
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_POINTS";
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_USED";
public static final String VITALITY_ITEMS_USED_VARIABLE_NAME = "VITALITY_ITEMS_USED";
private static final String DAILY_MISSION_REWARDS = "DAILY_MISSION_REWARDS";
public static final String CEREMONY_OF_CHAOS_PROHIBITED_PENALTIES = "CEREMONY_OF_CHAOS_PENALTIES";

View File

@@ -30,7 +30,7 @@ public class ExWorldChatCnt implements IClientOutgoingPacket
public ExWorldChatCnt(L2PcInstance activeChar)
{
_points = activeChar.getLevel() < Config.WORLD_CHAT_MIN_LEVEL ? 0 : activeChar.getWorldChatPoints();
_points = activeChar.getLevel() < Config.WORLD_CHAT_MIN_LEVEL ? 0 : Math.max(activeChar.getWorldChatPoints() - activeChar.getWorldChatUsed(), 0);
}
@Override