Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,122 +1,116 @@
|
||||
/*
|
||||
* 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.actor.instance.L2CubicInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoCubic;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Summon Cubic effect implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class SummonCubic extends AbstractEffect
|
||||
{
|
||||
/** Cubic ID. */
|
||||
private final int _cubicId;
|
||||
/** Cubic power. */
|
||||
private final int _cubicPower;
|
||||
/** Cubic duration. */
|
||||
private final int _cubicDuration;
|
||||
/** Cubic activation delay. */
|
||||
private final int _cubicDelay;
|
||||
/** Cubic maximum casts before going idle. */
|
||||
private final int _cubicMaxCount;
|
||||
/** Cubic activation chance. */
|
||||
private final int _cubicSkillChance;
|
||||
|
||||
public SummonCubic(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
|
||||
{
|
||||
super(attachCond, applyCond, set, params);
|
||||
|
||||
_cubicId = params.getInt("cubicId", -1);
|
||||
// Custom AI data.
|
||||
_cubicPower = params.getInt("cubicPower", 0);
|
||||
_cubicDuration = params.getInt("cubicDuration", 0);
|
||||
_cubicDelay = params.getInt("cubicDelay", 0);
|
||||
_cubicMaxCount = params.getInt("cubicMaxCount", -1);
|
||||
_cubicSkillChance = params.getInt("cubicSkillChance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstant()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(BuffInfo info)
|
||||
{
|
||||
if ((info.getEffected() == null) || !info.getEffected().isPlayer() || info.getEffected().isAlikeDead() || info.getEffected().getActingPlayer().inObserverMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cubicId < 0)
|
||||
{
|
||||
_log.warning(SummonCubic.class.getSimpleName() + ": Invalid Cubic ID:" + _cubicId + " in skill ID: " + info.getSkill().getId());
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = info.getEffected().getActingPlayer();
|
||||
if (player.inObserverMode() || player.isMounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Gnacik: TODO: Make better method of calculation.
|
||||
// If skill is enchanted calculate cubic skill level based on enchant
|
||||
// 8 at 101 (+1 Power)
|
||||
// 12 at 130 (+30 Power)
|
||||
// Because 12 is max 5115-5117 skills
|
||||
final int _cubicSkillLevel = info.getSkill().getLevel() > 100 ? ((info.getSkill().getLevel() - 100) / 7) + 8 : info.getSkill().getLevel();
|
||||
// If cubic is already present, it's replaced.
|
||||
final L2CubicInstance cubic = player.getCubicById(_cubicId);
|
||||
if (cubic != null)
|
||||
{
|
||||
cubic.stopAction();
|
||||
cubic.cancelDisappear();
|
||||
player.getCubics().remove(_cubicId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If maximum amount is reached, random cubic is removed.
|
||||
// Players with no mastery can have only one cubic.
|
||||
final int allowedCubicCount = info.getEffected().getActingPlayer().getStat().getMaxCubicCount();
|
||||
final int currentCubicCount = player.getCubics().size();
|
||||
// Extra cubics are removed, one by one, randomly.
|
||||
for (int i = 0; i <= (currentCubicCount - allowedCubicCount); i++)
|
||||
{
|
||||
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
|
||||
final L2CubicInstance removedCubic = player.getCubicById(removedCubicId);
|
||||
removedCubic.stopAction();
|
||||
removedCubic.cancelDisappear();
|
||||
player.getCubics().remove(removedCubic.getId());
|
||||
}
|
||||
}
|
||||
// Adding a new cubic.
|
||||
player.addCubic(_cubicId, _cubicSkillLevel, _cubicPower, _cubicDelay, _cubicSkillChance, _cubicMaxCount, _cubicDuration, info.getEffected() != info.getEffector());
|
||||
player.sendPacket(new ExUserInfoCubic(player));
|
||||
player.broadcastPacket(new CharInfo(player));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.CubicData;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CubicTemplate;
|
||||
import com.l2jmobius.gameserver.model.cubic.CubicInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoCubic;
|
||||
|
||||
/**
|
||||
* Summon Cubic effect implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class SummonCubic extends AbstractEffect
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(SummonCubic.class.getName());
|
||||
|
||||
private final int _cubicId;
|
||||
private final int _cubicLvl;
|
||||
|
||||
public SummonCubic(StatsSet params)
|
||||
{
|
||||
_cubicId = params.getInt("cubicId", -1);
|
||||
_cubicLvl = params.getInt("cubicLvl", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstant()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
|
||||
{
|
||||
if (!effected.isPlayer() || effected.isAlikeDead() || effected.getActingPlayer().inObserverMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cubicId < 0)
|
||||
{
|
||||
_log.warning(SummonCubic.class.getSimpleName() + ": Invalid Cubic ID:" + _cubicId + " in skill ID: " + skill.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = effected.getActingPlayer();
|
||||
if (player.inObserverMode() || player.isMounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If cubic is already present, it's replaced.
|
||||
final CubicInstance cubic = player.getCubicById(_cubicId);
|
||||
if (cubic != null)
|
||||
{
|
||||
if (cubic.getTemplate().getLevel() > _cubicLvl)
|
||||
{
|
||||
// What do we do in such case?
|
||||
return;
|
||||
}
|
||||
|
||||
cubic.deactivate();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If maximum amount is reached, random cubic is removed.
|
||||
// Players with no mastery can have only one cubic.
|
||||
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
|
||||
final int currentCubicCount = player.getCubics().size();
|
||||
// Extra cubics are removed, one by one, randomly.
|
||||
for (int i = 0; i <= (currentCubicCount - allowedCubicCount); i++)
|
||||
{
|
||||
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
|
||||
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
|
||||
removedCubic.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
final L2CubicTemplate template = CubicData.getInstance().getCubicTemplate(_cubicId, _cubicLvl);
|
||||
if (template == null)
|
||||
{
|
||||
LOGGER.warning("Attempting to summon cubic without existing template id: " + _cubicId + " level: " + _cubicLvl);
|
||||
return;
|
||||
}
|
||||
|
||||
// Adding a new cubic.
|
||||
player.addCubic(new CubicInstance(effected.getActingPlayer(), effector.getActingPlayer(), template));
|
||||
player.sendPacket(new ExUserInfoCubic(player));
|
||||
player.broadcastCharInfo();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user