Merged with released L2J-Unity files.
This commit is contained in:
104
trunk/dist/game/data/scripts/handlers/effecthandlers/SummonHallucination.java
vendored
Normal file
104
trunk/dist/game/data/scripts/handlers/effecthandlers/SummonHallucination.java
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.DoppelgangerInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.effects.L2EffectType;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class SummonHallucination extends AbstractEffect
|
||||
{
|
||||
private final int _despawnDelay;
|
||||
private final int _npcId;
|
||||
private final int _npcCount;
|
||||
|
||||
public SummonHallucination(StatsSet params)
|
||||
{
|
||||
_despawnDelay = params.getInt("despawnDelay", 20000);
|
||||
_npcId = params.getInt("npcId", 0);
|
||||
_npcCount = params.getInt("npcCount", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2EffectType getEffectType()
|
||||
{
|
||||
return L2EffectType.SUMMON_NPC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstant()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
|
||||
{
|
||||
if (effected.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_npcId <= 0) || (_npcCount <= 0))
|
||||
{
|
||||
_log.warning(SummonNpc.class.getSimpleName() + ": Invalid NPC ID or count skill ID: " + skill.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = effector.getActingPlayer();
|
||||
if (player.isMounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(_npcId);
|
||||
if (npcTemplate == null)
|
||||
{
|
||||
_log.warning(SummonNpc.class.getSimpleName() + ": Spawn of the nonexisting NPC ID: " + _npcId + ", skill ID:" + skill.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
int x = effected.getX();
|
||||
int y = effected.getY();
|
||||
final int z = effected.getZ();
|
||||
|
||||
for (int i = 0; i < _npcCount; i++)
|
||||
{
|
||||
x += (Rnd.nextBoolean() ? Rnd.get(0, 20) : Rnd.get(-20, 0));
|
||||
y += (Rnd.nextBoolean() ? Rnd.get(0, 20) : Rnd.get(-20, 0));
|
||||
|
||||
final DoppelgangerInstance clone = new DoppelgangerInstance(npcTemplate, player);
|
||||
clone.setCurrentHp(clone.getMaxHp());
|
||||
clone.setCurrentMp(clone.getMaxMp());
|
||||
clone.setSummoner(player);
|
||||
clone.spawnMe(x, y, z);
|
||||
clone.scheduleDespawn(_despawnDelay);
|
||||
clone.doAttack(effected);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user