Help in Skills !

jocker23

Пляшущий с бубном
Участник
Сообщения
78
Розыгрыши
0
Репутация
29
Реакции
4
Баллы
260
Хроники
  1. Master Class
Исходники
Присутствуют
Сборка
L2JMobius
Trying to set up the new Summon Elf's skill, I'm stuck with a problem.

I'm using L2JMobius 8.3 Guardian

How am I going to make Summon replicate the Player skills?

I tried to use as base the skill 4* Divine Templar but I'm not getting success!

I would like not to appear HP and MP the Summon Bar like PET/SERVICE !

XML:
<skill id="88291" toLevel="1" name="Summon Elemental Unicorn">
        <!-- <<font color="00FF00">Summon skill</font>>. Summons an <font color="5599ff">Elemental Unicorn</font> near the caster. The <font color="5599ff">Elemental Unicorn's</font> base combat stats:. - The summoner's combat stats transfer 5%. Only 1 <font color="5599ff">Elemental Unicorn</font> can be summoned at a time. -->
        <icon>icon.s_elemental_unicorn_1st</icon>
        <operateType>A2</operateType>
        <isMagic>1</isMagic> <!-- Magic Skill -->
        <hitTime>1000</hitTime>
        <reuseDelay>10000</reuseDelay>
        <abnormalTime>1200</abnormalTime>
        <mpConsume>50</mpConsume>
        <targetType>SELF</targetType>
        <affectScope>SINGLE</affectScope>
        <itemConsumeCount>50</itemConsumeCount>
        <itemConsumeId>3031</itemConsumeId> <!-- Spirit Ore -->
        <conditions>
            <condition name="CanSummon" />
            <condition name="Op2hWeapon">
                <weaponType>
                    <item>BLUNT</item>
                </weaponType>
            </condition>
        </conditions>
        <effects>
            <effect name="Summon">
                <npcId>17000</npcId>
            </effect>
        </effects>
    </skill>


XML:
<npc id="17000" level="85" type="Guardian" name="Elemental Unicorn">
        <!-- AUTO GENERATED NPC TODO: FIX IT -->
        <parameters>
            <skill name="Elemental Discharge" id="88279" level="20" /> <!-- Elemental Discharge -->
        </parameters>
        <race>ELEMENTAL</race>
        <sex>MALE</sex>
        <stats str="88" int="79" dex="55" wit="78" con="82" men="78">
            <vitals hp="4300" hpRegen="10.5" mp="1778" mpRegen="3.6" />
            <speed>
                <walk ground="60" />
                <run ground="350" />
            </speed>
            <attack physical="1950.2231755595" magical="1331.5869440987" critical="4" attackSpeed="253" range="40" />
            <defence physical="405.85106382979" magical="297.0297029703" />
        </stats>
        <status attackable="false" />
        <collision>
            <radius normal="0.1" />
            <height normal="23" />
        </collision>
        <skillList>
            <skill id="88279" level="1" /> <!-- Elemental Discharge -->
        </skillList>
    </npc>

Java:
package handlers.effecthandlers;

import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.NpcData;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.enums.creature.Race;
import org.l2jmobius.gameserver.model.actor.instance.Servitor;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.effects.EffectType;
import org.l2jmobius.gameserver.model.item.holders.ItemHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.BuffInfo;
import org.l2jmobius.gameserver.model.skill.Skill;

/**
 * Summon effect implementation.
 * @author UnAfraid
 */
public class Summon extends AbstractEffect
{
    private final int _npcId;
    private final float _expMultiplier;
    private final ItemHolder _consumeItem;
    private final int _lifeTime;
    private final int _consumeItemInterval;
   
    public Summon(StatSet params)
    {
        if (params.isEmpty())
        {
            throw new IllegalArgumentException("Summon effect without parameters!");
        }
       
        _npcId = params.getInt("npcId");
        _expMultiplier = params.getFloat("expMultiplier", 1);
        _consumeItem = new ItemHolder(params.getInt("consumeItemId", 0), params.getInt("consumeItemCount", 1));
        _consumeItemInterval = params.getInt("consumeItemInterval", 0);
        _lifeTime = params.getInt("lifeTime", 0) > 0 ? params.getInt("lifeTime") * 1000 : -1; // Classic change.
    }
   
    @Override
    public EffectType getEffectType()
    {
        return EffectType.SUMMON;
    }
   
    @Override
    public boolean isInstant()
    {
        return true;
    }
   
    @Override
    public void instant(Creature effector, Creature effected, Skill skill, Item item)
    {
        if (!effected.isPlayer())
        {
            return;
        }
       
        final Player player = effected.asPlayer();
        if (player.hasServitors())
        {
            player.getServitors().values().forEach(s -> s.unSummon(player));
        }
       
        final NpcTemplate template = NpcData.getInstance().getTemplate(_npcId);
        final Servitor summon = new Servitor(template, player);
        final int consumeItemInterval = (_consumeItemInterval > 0 ? _consumeItemInterval : (template.getRace() != Race.SIEGE_WEAPON ? 240 : 60)) * 1000;
       
        summon.setName(template.getName());
        summon.setTitle(effected.getName());
        summon.setReferenceSkill(skill.getId());
        summon.setExpMultiplier(_expMultiplier);
        summon.setLifeTime(_lifeTime <= 0 ? Integer.MAX_VALUE : _lifeTime); // Classic hack. Resummon upon entering game.
        summon.setItemConsume(_consumeItem);
        summon.setItemConsumeInterval(consumeItemInterval);
       
        final int maxPetLevel = ExperienceData.getInstance().getMaxPetLevel();
        if (summon.getLevel() >= maxPetLevel)
        {
            summon.getStat().setExp(ExperienceData.getInstance().getExpForLevel(maxPetLevel - 1));
        }
        else
        {
            summon.getStat().setExp(ExperienceData.getInstance().getExpForLevel(summon.getLevel() % maxPetLevel));
        }
       
        // Summons must have their master buffs upon spawn.
        for (BuffInfo effect : player.getEffectList().getEffects())
        {
            final Skill sk = effect.getSkill();
            if (!sk.isBad() && !sk.isTransformation() && skill.isSharedWithSummon())
            {
                sk.applyEffects(player, summon, false, effect.getTime());
            }
        }
       
        summon.setCurrentHp(summon.getMaxHp());
        summon.setCurrentMp(summon.getMaxMp());
        summon.setHeading(player.getHeading());
       
        player.addServitor(summon);
       
        summon.setShowSummonAnimation(true);
        summon.spawnMe();
        summon.setRunning();
    }
}

Java:
package handlers.effecthandlers;

import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.NpcData;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.instance.Guardian;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.effects.EffectType;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;

/**
 * @author Liamxroy
 */
public class SummonGuardian extends AbstractEffect
{
    private final int _despawnDelay;
    private final int _npcId;
    private final int _npcCount;
    private final boolean _singleInstance; // Only one instance of this NPC is allowed.
   
    public SummonGuardian(StatSet params)
    {
        _despawnDelay = params.getInt("despawnDelay", 20000);
        _npcId = params.getInt("npcId", 0);
        _npcCount = params.getInt("npcCount", 1);
        _singleInstance = params.getBoolean("singleInstance", false);
    }
   
    @Override
    public EffectType getEffectType()
    {
        return EffectType.SUMMON_NPC;
    }
   
    @Override
    public boolean isInstant()
    {
        return true;
    }
   
    @Override
    public void instant(Creature effector, Creature effected, Skill skill, Item item)
    {
        if (effected.isAlikeDead())
        {
            return;
        }
       
        if ((_npcId <= 0) || (_npcCount <= 0))
        {
            LOGGER.warning(SummonNpc.class.getSimpleName() + ": Invalid NPC ID or count skill ID: " + skill.getId());
            return;
        }
       
        final Player player = effector.asPlayer();
        if (player.isMounted())
        {
            return;
        }
       
        final NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(_npcId);
        if (npcTemplate == null)
        {
            LOGGER.warning(SummonNpc.class.getSimpleName() + ": Spawn of the nonexisting NPC ID: " + _npcId + ", skill ID:" + skill.getId());
            return;
        }
       
        // If only single instance is allowed, delete previous NPCs.
        if (_singleInstance)
        {
            for (Npc npc : player.getSummonedNpcs())
            {
                if (npc.getId() == _npcId)
                {
                    npc.deleteMe();
                }
            }
        }
       
        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 Guardian clone = new Guardian(npcTemplate, player);
            player.addSummonedNpc(clone);
            clone.setCurrentHp(clone.getMaxHp());
            clone.setCurrentMp(clone.getMaxMp());
            clone.setSummoner(player);
            clone.spawnMe(x, y, z);
            clone.setRunning();
            clone.scheduleDespawn(_despawnDelay);
            clone.startAttackTask();
        }
    }
}

I tried to make a junction with the 2 Effecthandlers but it didn't come out as expected ... :(
 

Похожие темы

Назад
Сверху