Addition of HitAtNight effect.

This commit is contained in:
MobiusDev
2018-12-15 20:42:26 +00:00
parent 0730202378
commit 09cfaab4f2
80 changed files with 940 additions and 20 deletions

View File

@@ -162,6 +162,7 @@ public final class EffectMasterHandler
EffectHandler.getInstance().registerHandler("HealOverTime", HealOverTime::new);
EffectHandler.getInstance().registerHandler("HealPercent", HealPercent::new);
EffectHandler.getInstance().registerHandler("Hide", Hide::new);
EffectHandler.getInstance().registerHandler("HitAtNight", HitAtNight::new);
EffectHandler.getInstance().registerHandler("HitNumber", HitNumber::new);
EffectHandler.getInstance().registerHandler("Hp", Hp::new);
EffectHandler.getInstance().registerHandler("HpByLevel", HpByLevel::new);

View File

@@ -0,0 +1,46 @@
/*
* 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.GameTimeController;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
/**
* @author Mobius
*/
public class HitAtNight extends AbstractStatEffect
{
public HitAtNight(StatsSet params)
{
super(params, Stats.HIT_AT_NIGHT);
}
@Override
public void onStart(L2Character effector, L2Character effected, Skill skill)
{
GameTimeController.getInstance().addShadowSenseCharacter(effected);
}
@Override
public void onExit(L2Character effector, L2Character effected, Skill skill)
{
GameTimeController.getInstance().removeShadowSenseCharacter(effected);
}
}

View File

@@ -7200,7 +7200,7 @@
<operateType>P</operateType>
<magicCriticalRate>5</magicCriticalRate>
<effects>
<effect name="Accuracy">
<effect name="HitAtNight">
<amount>3</amount>
<mode>DIFF</mode>
</effect>

View File

@@ -132,6 +132,7 @@ Heal: Increases current HP by a given amount.
HealOverTime: Increases current HP by a given amount over time.
HealPercent: Increases current HP by a given percentage amount.
Hide: Hide effect.
HitAtNight: Used by Shadow Sense to modify Accuracy at night. (l2jmobius)
HitNumber: Polearm attack max hit creatures.
HpByLevel: recovers certain amount of HP, but current implementation is wrong... final amount should be computed from skill power and character level difference
HpCpHealCritical: HpCp heal effects always trigger Magic Critical Hit.

View File

@@ -25,6 +25,8 @@ import java.util.logging.Logger;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Game Time controller class.
@@ -40,10 +42,12 @@ public final class GameTimeController extends Thread
public static final int MILLIS_PER_IG_DAY = (3600000 * 24) / IG_DAYS_PER_DAY;
public static final int SECONDS_PER_IG_DAY = MILLIS_PER_IG_DAY / 1000;
public static final int TICKS_PER_IG_DAY = SECONDS_PER_IG_DAY * TICKS_PER_SECOND;
private final static int SHADOW_SENSE_ID = 294;
private static GameTimeController _instance;
private final Set<L2Character> _movingObjects = ConcurrentHashMap.newKeySet();
private final Set<L2Character> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
private final long _referenceTime;
private GameTimeController()
@@ -174,12 +178,42 @@ public final class GameTimeController extends Thread
if (isNight() != isNight)
{
isNight = !isNight;
EventDispatcher.getInstance().notifyEventAsync(new OnDayNightChange(isNight));
notifyShadowSense();
}
}
}
public synchronized void addShadowSenseCharacter(L2Character character)
{
if (!_shadowSenseCharacters.contains(character))
{
_shadowSenseCharacters.add(character);
if (isNight())
{
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT);
msg.addSkillName(SHADOW_SENSE_ID);
character.sendPacket(msg);
}
}
}
public void removeShadowSenseCharacter(L2Character character)
{
_shadowSenseCharacters.remove(character);
}
private void notifyShadowSense()
{
final SystemMessage msg = SystemMessage.getSystemMessage(isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR);
msg.addSkillName(SHADOW_SENSE_ID);
for (L2Character character : _shadowSenseCharacters)
{
character.getStat().recalculateStats(true);
character.sendPacket(msg);
}
}
public static GameTimeController getInstance()
{
return _instance;

View File

@@ -2575,6 +2575,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
case MAGIC_ATTACK:
case MAGIC_ATTACK_SPEED:
case MAGICAL_DEFENCE:
case HIT_AT_NIGHT:
{
info.addComponentType(UserInfoType.STATS);
break;

View File

@@ -149,6 +149,8 @@ public enum Stats
MAGIC_ATTACK_RANGE("mAtkRange"),
ATTACK_COUNT_MAX("atkCountMax"),
PHYSICAL_POLEARM_TARGET_SINGLE("polearmSingleTarget"),
HIT_AT_NIGHT("hitAtNight"),
// Run speed, walk & escape speed are calculated proportionally, magic speed is a buff
MOVE_SPEED("moveSpeed"),
RUN_SPEED("runSpd", new SpeedFinalizer()),

View File

@@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -69,6 +70,12 @@ public class PAccuracyFinalizer implements IStatsFunction
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_GLOVES);
}
// Shadow sense
if (GameTimeController.getInstance().isNight())
{
baseValue += creature.getStat().getAdd(Stats.HIT_AT_NIGHT, 0);
}
return Stats.defaultValue(creature, stat, baseValue);
}