Reworked GameTime task manager.
This commit is contained in:
@@ -175,7 +175,6 @@ public 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);
|
||||
@@ -333,6 +332,7 @@ public class EffectMasterHandler
|
||||
EffectHandler.getInstance().registerHandler("SpModify", SpModify::new);
|
||||
EffectHandler.getInstance().registerHandler("Spoil", Spoil::new);
|
||||
EffectHandler.getInstance().registerHandler("StatAddForLevel", StatAddForLevel::new);
|
||||
EffectHandler.getInstance().registerHandler("StatAddForNight", StatAddForNight::new);
|
||||
EffectHandler.getInstance().registerHandler("StatBonusSkillCritical", StatBonusSkillCritical::new);
|
||||
EffectHandler.getInstance().registerHandler("StatBonusSpeed", StatBonusSpeed::new);
|
||||
EffectHandler.getInstance().registerHandler("StatByMoveType", StatByMoveType::new);
|
||||
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class HitAtNight extends AbstractStatEffect
|
||||
{
|
||||
public HitAtNight(StatSet params)
|
||||
{
|
||||
super(params, Stat.HIT_AT_NIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Creature effector, Creature effected, Skill skill, Item item)
|
||||
{
|
||||
GameTimeTaskManager.getInstance().addShadowSenseCharacter(effected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit(Creature effector, Creature effected, Skill skill)
|
||||
{
|
||||
GameTimeTaskManager.getInstance().removeShadowSenseCharacter(effected);
|
||||
}
|
||||
}
|
130
L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/StatAddForNight.java
vendored
Normal file
130
L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/StatAddForNight.java
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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 java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.StatModifierType;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import org.l2jmobius.gameserver.model.events.Containers;
|
||||
import org.l2jmobius.gameserver.model.events.EventType;
|
||||
import org.l2jmobius.gameserver.model.events.ListenersContainer;
|
||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class StatAddForNight extends AbstractEffect
|
||||
{
|
||||
private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight());
|
||||
private static final Set<Creature> NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet();
|
||||
private static final int SHADOW_SENSE = 294;
|
||||
|
||||
private final Stat _stat;
|
||||
private final int _amount;
|
||||
protected final StatModifierType _mode;
|
||||
|
||||
public StatAddForNight(StatSet params)
|
||||
{
|
||||
_stat = params.getEnum("stat", Stat.class);
|
||||
_amount = params.getInt("amount");
|
||||
_mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF);
|
||||
|
||||
// Init a global day-night change listener.
|
||||
final ListenersContainer container = Containers.Global();
|
||||
container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Creature effector, Creature effected, Skill skill, Item item)
|
||||
{
|
||||
NIGHT_STAT_CHARACTERS.add(effected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit(Creature effector, Creature effected, Skill skill)
|
||||
{
|
||||
NIGHT_STAT_CHARACTERS.remove(effected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pump(Creature effected, Skill skill)
|
||||
{
|
||||
// Not night.
|
||||
if (!GameTimeTaskManager.getInstance().isNight())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply stat.
|
||||
switch (_mode)
|
||||
{
|
||||
case DIFF:
|
||||
{
|
||||
effected.getStat().mergeAdd(_stat, _amount);
|
||||
break;
|
||||
}
|
||||
case PER:
|
||||
{
|
||||
effected.getStat().mergeMul(_stat, (_amount / 100) + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onDayNightChange(OnDayNightChange event)
|
||||
{
|
||||
synchronized (DAY_TIME)
|
||||
{
|
||||
final boolean isNight = event.isNight();
|
||||
|
||||
// Run only once per daytime change.
|
||||
if (isNight == DAY_TIME.get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
DAY_TIME.set(isNight);
|
||||
|
||||
// System message for Shadow Sense.
|
||||
final SystemMessage msg = new SystemMessage(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);
|
||||
|
||||
for (Creature creature : NIGHT_STAT_CHARACTERS)
|
||||
{
|
||||
// Pump again.
|
||||
creature.getStat().recalculateStats(true);
|
||||
|
||||
// Send Shadow Sense message when player has skill.
|
||||
if (creature.getKnownSkill(SHADOW_SENSE) != null)
|
||||
{
|
||||
creature.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -6462,9 +6462,9 @@
|
||||
<operateType>P</operateType>
|
||||
<magicCriticalRate>5</magicCriticalRate>
|
||||
<effects>
|
||||
<effect name="HitAtNight">
|
||||
<effect name="StatAddForNight">
|
||||
<stat>ACCURACY_COMBAT</stat>
|
||||
<amount>3</amount>
|
||||
<mode>DIFF</mode>
|
||||
</effect>
|
||||
</effects>
|
||||
</skill>
|
||||
|
@@ -146,7 +146,6 @@ 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.
|
||||
@@ -301,6 +300,7 @@ SpeedLimit: Increase a character's max Speed limit. (l2jmobius)
|
||||
SpModify: Bonus SP stat.
|
||||
Spoil: Spoils a mob activating its extra sweep drop.
|
||||
StatAddForLevel: Adds a fixed amount of a Stat for a specific player level. (l2jmobius)
|
||||
StatAddForNight: Modify a specific stat at night time. (l2jmobius)
|
||||
StatBonusSkillCritical: Changes skill critical rate to depend on the specified base stat.
|
||||
StatBonusSpeed: Changes Speed stat to depend on the specified base stat.
|
||||
StatByMoveType: Adds stat based on your movement type (standing, running, walking).
|
||||
|
Reference in New Issue
Block a user