Jump to content

Sabrent

Members
  • Posts

    21
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Sabrent

  1. What I want is that when the item is finished, the player is teleport to another site.

     

    my script

    /**
     * MyNpc AI.
     */
    public final class MyNpc extends AbstractNpcAI
    {
    	// NPC
    	private static final int NPC1 = 36655;
    	private static final int NPC2 = 36656;
    	// Item
    	private static final int ITEM_NAME = 47811;
    
    	private static final Location DIMENSIONAL = new Location(-190313, -112464, -7752);
    
    	private MyNpc()
    	{
    		addStartNpc(NPC1, NPC2);
    		addTalkId(NPC1, NPC2);
    		addFirstTalkId(NPC1, NPC2);
    	}
    
    	@Override
    	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    	{
    		String htmltext = null;
    		if (npc.getId() == NPC1)
    		{
    			switch (event)
    			{
    				case "36655.htm":
    				{
    					htmltext = event;
    					break;
    				}
    				case "give_coin":
    				{
    					if (hasQuestItems(player, ITEM_NAME))
    					{
    						return "haveitem_b.htm";
    					}else
    					{
    						giveItems(player, ITEM_NAME, 1);
    						playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
    					}
    				}
    			}
    			break;
    		}
    	}
    	if (npc.getId() == NPC2)
    	{
    		switch (event)
    		{
    			case "36656.htm":
    			{
    				htmltext = event;
    				break;
    			}
    			case "give_coin":
    			{
    				if (hasQuestItems(player, ITEM_NAME))
    				{
    					return "haveitem_s.htm";
    				}
    				else
    				{
    					giveItems(player, ITEM_NAME, 1);
    					playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
    				}
    			}
    		}
    		break;
    	}
    
    }
    return htmltext;
    
    }
    
    @Override
    public String onFirstTalk(L2Npc npc, L2PcInstance player) {
    	String htmltext = null;
    	switch (npc.getId())
    	{
    		case NPC1:
    		{
    			htmltext = "36655.htm";
    			break;
    		}
    		case NPC2:
    		{
    			htmltext = "36656.htm";
    			break;
    		}
    	}
    	return htmltext;
    }
    
    public void onItemExpire(L2Item item)
    {
    	L2PcInstance player = null;
    	if (item.getId() == ITEM_NAME)
    	{
    		if (item.getId() == -1)
    		{
    			player.teleToLocation(DIMENSIONAL);
    		}
    	}
    
    }
    
    
    public static void main(String[] args) { new MyNpc(); }
    }

    try custom item and skill and it not work

    	<skill id="55032" displayId="770" toLevel="1" name="Dimensional">
    		<magicLvl>1</magicLvl>
    		<operateType>P</operateType>
    		<targetType>SELF</targetType>
    		<affectScope>SINGLE</affectScope>
    		<conditions>
    			<condition name="OpCanEscape" />
    		</conditions>
    		<effects>
    			<effect name="Teleport">
    				<x>-120313</x>
    				<y>-182464</y>
    				<z>-6752</z>
    			</effect>
    		</effects>
    	</skill>
    
    	<item id="47811" name="Dimensional" type="EtcItem">
    		<set name="is_tradable" val="false" />
    		<set name="immediate_effect" val="true" />
    		<set name="is_oly_restricted" val="true" />
    		<set name="handler" val="ItemSkills" />
    		<set name="is_dropable" val="false" />
    		<set name="is_destroyable" val="false" />
    		<set name="is_depositable" val="false" />
    		<set name="is_sellable" val="false" />
    		<set name="is_clan_depositable" val="false" />
    		<set name="is_mailable" val="false" />
    		<set name="is_commissionable" val="false" />
    		<set name="is_private_storeable" val="false" />
    		<set name="is_stackable" val="false" />
    		<set name="time" val="60" /><!-- Mints -->
    		<skills>
    			<skill id="55032" level="1" /> <!-- Dimensional -->
    		</skills>
    	</item>

     

  2. 12 hours ago, Tryskell said:

    By "expired item", I suppose you speak about Shadow Weapon. PostIL chronicles probably uses the same timer/engine anyway.

     

    On aCis, it would be located into ShadowItemTaskManager#run() method, in the following "if" block :

    
    if (mana == -1)

    If you use another pack, simply search for S1S_REMAINING_MANA_IS_NOW_0 which is the destruction of the item when mana reached 0.

     

    If it's another system, simply check which message is sent when item is destroyed or when time expires, and put your teleToLocation in the block.

    Yeah! :cheer:

    I was observing the examples in L2ItemInstance and L2Item on the getTime and getDuration of the mana, I also observed the behavior of the shadows weapons and cursed weapons, try to do a method, but I am not an expert in Java but I am a student and I am not ashamed to ask.

     

    1 hour ago, etherian said:



    you can achieve such thing by making a custom item / custom skill
    why you want to use script ?

    suggestion / example
     

    <set name="duration" val="600" />


    <set name="targetType" val="SELF" />

        <effects>
                <effect name="Escape">
                    <param escapeType="TOWN" />
                </effect>
            </effects>
        </skill>


    ************************************************

    the only pathetic here is you Kara'
    get a transformation into a fem  you rly need it.


     

    Thx friend :cheer:

  3. Hi friends.
    I'm doing a method where when the item expires teleport the player to another site.

     

    	public void onItemExpire(L2Item item)
    	{
    		L2PcInstance player = null;
    		if (item.getId() == ITEM_NAME)
    		{
    			if (item.getId() == -1)
    			{
    				player.teleToLocation(DIMENSIONAL_CRACK);
    			}
    		}
    
    	}

    some developer colleague can give me some suggestion?
    thx :alone:

  4. L2Character (2729)

    	public boolean updatePosition()
    	{
    		// Get movement data
    		MoveData m = _move;
    		
    		if (m == null)
    		{
    			return true;
    		}
    		
    		if (!isSpawned())
    		{
    			_move = null;
    			return true;
    		}
    		
    		// Check if this is the first update
    		if (m._moveTimestamp == 0)
    		{
    			m._moveTimestamp = m._moveStartTime;
    			m._xAccurate = getX();
    			m._yAccurate = getY();
    		}
    		
    		int gameTicks = GameTimeManager.getInstance().getGameTicks();
    		
    		// Check if the position has already been calculated
    		if (m._moveTimestamp == gameTicks)
    		{
    			return false;
    		}
    		
    		double xPrev = getX();
    		double yPrev = getY();
    		double zPrev = getZ(); // the z coordinate may be modified by coordinate synchronizations
    		
    		double dx, dy, dz;
    		if (GeoDataConfig.COORD_SYNCHRONIZE == 1)
    		// the only method that can modify x,y while moving (otherwise _move would/should be set null)
    		{
    			dx = m._xDestination - xPrev;
    			dy = m._yDestination - yPrev;
    		}
    		else
    		// otherwise we need saved temporary values to avoid rounding errors
    		{
    			dx = m._xDestination - m._xAccurate;
    			dy = m._yDestination - m._yAccurate;
    		}
    		
    		final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER);
    		
    		// Z coordinate will follow geodata or client values
    		if ((GeoDataConfig.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeManager.getInstance().getGameTicks() % 10) == 0 // once a second to reduce possible cpu load
    		) && GeoData.getInstance().hasGeo(xPrev, yPrev))
    		{
    			double geoHeight = GeoData.getInstance().getSpawnHeight(xPrev, yPrev, zPrev);
    			dz = m._zDestination - geoHeight;
    			// quite a big difference, compare to validatePosition packet
    			if (isPlayer() && (Math.abs(getActingPlayer().getClientZ() - geoHeight) > 200) && (Math.abs(getActingPlayer().getClientZ() - geoHeight) < 1500))
    			{
    				dz = m._zDestination - zPrev; // allow diff
    			}
    			else if (isInCombat() && (Math.abs(dz) > 200) && (((dx * dx) + (dy * dy)) < 40000)) // allow mob to climb up to pcinstance
    			{
    				dz = m._zDestination - zPrev; // climbing
    			}
    			else
    			{
    				zPrev = geoHeight;
    			}
    		}
    		else
    		{
    			dz = m._zDestination - zPrev;
    		}
    		
    		double delta = (dx * dx) + (dy * dy);
    		if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided
    			&& !isFloating)
    		{
    			delta = Math.sqrt(delta);
    		}
    		else
    		{
    			delta = Math.sqrt(delta + (dz * dz));
    		}
    		
    		double distFraction = Double.MAX_VALUE;
    		if (delta > 1)
    		{
    			final double distPassed = (getMoveSpeed() * (gameTicks - m._moveTimestamp)) / GameTimeManager.TICKS_PER_SECOND;
    			distFraction = distPassed / delta;
    		}
    		
    		// if (Config.DEVELOPER) LOGGER.warn("Move Ticks:" + (gameTicks - m._moveTimestamp) + ", distPassed:" + distPassed + ", distFraction:" + distFraction);
    		
    		if (distFraction > 1)
    		{
    			// Set the position of the L2Character to the destination
    			final double x = m._xDestination;
    			final double y = m._yDestination;
    			final double z = m._zDestination;
    			
    			super.setXYZ(x, y, z);
    			
    			if (isDebug())
    			{
    				final ExShowTrace trace = new ExShowTrace();
    				trace.addLocation(x, y, z);
    				sendDebugPacket(trace, DebugType.MOVEMENT);
    			}
    		}
    		else
    		{
    			m._xAccurate += dx * distFraction;
    			m._yAccurate += dy * distFraction;
    			
    			final double x = m._xAccurate;
    			final double y = m._yAccurate;
    			final double z = zPrev + ((dz * distFraction) + 0.5);
    			
    			// Set the position of the L2Character to estimated after partial move
    			super.setXYZ(x, y, z); // HERE  LINE 2729
    			
    			if (isDebug())
    			{
    				final ExShowTrace trace = new ExShowTrace();
    				trace.addLocation(x, y, z);
    				sendDebugPacket(trace, DebugType.MOVEMENT);
    			}
    		}
    		revalidateZone(false);
    		
    		// Set the timer of last position update to now
    		m._moveTimestamp = gameTicks;
    		
    		if (distFraction > 1)
    		{
    			if (isDebug())
    			{
    				Position.drawPosition(this);
    			}
    			
    			ThreadPool.execute(() -> getAI().notifyEvent(CtrlEvent.EVT_ARRIVED));
    			return true;
    		}
    		
    		return false;
    	}

     

  5. Hello friends.

     

    I have a doubt with this Exception: Null, in my knowledge, which is not much, I am looking for the object that has not been initialized, i has it took several days looking how to solve it.

     

    Quote

    World: Incorrect world region X: 229 Y: 71 Z: 33 for coordinates x: 175890.18344142888 y: -116237.71868332032 z: 17408.181400724894
    java.lang.NullPointerException: null
        at l2jlove.gameserver.model.L2Object.setXYZ(L2Object.java:780)
        at l2jlove.gameserver.model.actor.L2Character.updatePosition(L2Character.java:2927)
        at java.util.Collection.removeIf(Unknown Source)
        at .gameserver.taskmanager.MovementController.run(MovementController.java:74)
        at l2jlove.gameserver.commons.util.concurrent.RunnableWrapper.run(RunnableWrapper.java:40)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unkno wn Source)

     

    L2Object.java:780

    	@Override
    	public void setXYZ(double x, double y, double z)
    	{
    		_x = x;
    		_y = y;
    		_z = z;
    		
    		if (_isSpawned)
    		{
    			final WorldRegion oldRegion = getWorldRegion();
    			final WorldRegion newRegion = World.getInstance().getRegion(this);
    			if (newRegion != oldRegion)
    			{
    				if (oldRegion != null)
    				{
    					oldRegion.removeVisibleObject(this);
    				}
    				newRegion.addVisibleObject(this);
    				World.getInstance().switchRegion(this, newRegion);
    				setWorldRegion(newRegion);
    			}
    		}
    	}

     

     

  6. public class SkillData implements IGameXmlReader
    {
    	private static final Logger LOGGER = Logger.getLogger(SkillData.class.getName());
    
    	private final Map<Long, Skill> _skills = new HashMap<>();
    	private final Map<Integer, Integer> _skillsMaxLevel = new HashMap<>();
    
    	private class NamedParamInfo
    	{
    		private final String _name;
    		private final Integer _fromLevel;
    		private final Integer _toLevel;
    		private final Integer _fromSubLevel;
    		private final Integer _toSubLevel;
    		private final Map<Integer, Map<Integer, StatsSet>> _info;
    
    		public NamedParamInfo(String name, Integer fromLevel, Integer toLevel, Integer fromSubLevel, Integer toSubLevel, Map<Integer, Map<Integer, StatsSet>> info)
    		{
    			_name = name;
    			_fromLevel = fromLevel;
    			_toLevel = toLevel;
    			_fromSubLevel = fromSubLevel;
    			_toSubLevel = toSubLevel;
    			_info = info;
    		}
    
    		public String getName()
    		{
    			return _name;
    		}
    
    		public Integer getFromLevel()
    		{
    			return _fromLevel;
    		}
    
    		public Integer getToLevel()
    		{
    			return _toLevel;
    		}
    
    		public Integer getFromSubLevel()
    		{
    			return _fromSubLevel;
    		}
    
    		public Integer getToSubLevel()
    		{
    			return _toSubLevel;
    		}
    
    		public Map<Integer, Map<Integer, StatsSet>> getInfo()
    		{
    			return _info;
    		}
    	}
    
    	protected SkillData()
    	{
    		load();
    	}
    	
    	public static long getSkillHashCode(Skill skill)
    	{
    		return getSkillHashCode(skill.getId(), skill.getLevel(), skill.getSubLevel());
    	}
    	
    	public static long getSkillHashCode(int skillId, int skillLevel)
    	{
    		return getSkillHashCode(skillId, skillLevel, 0);
    	}
    	
    	public static long getSkillHashCode(int skillId, int skillLevel, int subSkillLevel)
    	{
    		return subSkillLevel > 0 ? ((skillId * 4294967296L) + (subSkillLevel * 65536) + skillLevel) : (skillId * 65536) + skillLevel;
    	}
    
    	public Skill getSkill(int skillId, int level)
    	{
    		return getSkill(skillId, level, 0);
    	}
    
    	public Skill getSkill(int skillId, int level, int subLevel)
    	{
    		final Skill result = _skills.get(getSkillHashCode(skillId, level, subLevel));
    		if (result != null)
    		{
    			return result;
    		}
    
    		
    		final int maxLvl = getMaxLevel(skillId);
    		
    		if ((maxLvl > 0) && (level > maxLvl))
    		{
    			LOGGER.log(Level.WARNING, this.getClass().getSimpleName() + ": Call to unexisting skill level id: " + skillId + " requested level: " + level + " max level: " + maxLvl + ".", new Throwable());
    			return _skills.get(getSkillHashCode(skillId, maxLvl, 0));
    		}
    
    		LOGGER.warning(this.getClass().getSimpleName() + ": No skill info found for skill id " + skillId + " and skill level " + level);
    		return null;
    	}
    
    	public int getMaxLevel(int skillId)
    	{
    		final Integer maxLevel = _skillsMaxLevel.get(skillId);
    		return maxLevel != null ? maxLevel : 0;
    	}
    
    
    	public List<Skill> getSiegeSkills(boolean addNoble, boolean hasCastle)
    	{
    		final List<Skill> temp = new LinkedList<>();
    
    		temp.add(_skills.get(SkillData.getSkillHashCode(CommonSkill.IMPRIT_OF_LIGHT.getId(), 1)));
    		temp.add(_skills.get(SkillData.getSkillHashCode(CommonSkill.IMPRIT_OF_DARKNESS.getId(), 1)));
    
    		temp.add(_skills.get(SkillData.getSkillHashCode(247, 1))); 
    
    		if (addNoble)
    		{
    			temp.add(_skills.get(SkillData.getSkillHashCode(326, 1))); 
    		}
    		if (hasCastle)
    		{
    			temp.add(_skills.get(SkillData.getSkillHashCode(844, 1))); 
    			temp.add(_skills.get(SkillData.getSkillHashCode(845, 1))); 
    		}
    		return temp;
    	}
    
    	@Override
    	public boolean isValidating()
    	{
    		return false;
    	}
    
    	@Override
    	public synchronized void load()
    	{
    		_skills.clear();
    		_skillsMaxLevel.clear();
    		parseDatapackDirectory("data/stats/skills/", true);
    		LOGGER.info(this.getClass().getSimpleName() + ": Loaded " + this._skills.size() + " Skills.");
    	}
    
    	public void reload()
    	{
    		load();
    		SkillTreesData.getInstance().load();
    	}
    
    	@Override
    	public void parseDocument(Document doc, File f)
    	{
    		for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling())
    		{
    			if ("list".equalsIgnoreCase(node.getNodeName()))
    			{
    				for (Node listNode = node.getFirstChild(); listNode != null; listNode = listNode.getNextSibling())
    				{
    					if ("skill".equalsIgnoreCase(listNode.getNodeName()))
    					{
    						NamedNodeMap attributes = listNode.getAttributes();
    						final Map<Integer, Set<Integer>> levels = new HashMap<>();
    						final Map<Integer, Map<Integer, StatsSet>> skillInfo = new HashMap<>();
    						final StatsSet generalSkillInfo = skillInfo.computeIfAbsent(-1, (k) -> new HashMap<>()).computeIfAbsent(-1, (k) -> new StatsSet());
    
    						parseAttributes(attributes, "", generalSkillInfo);
    
    						final Map<String, Map<Integer, Map<Integer, Object>>> variableValues = new HashMap<>();
    						final Map<EffectScope, List<NamedParamInfo>> effectParamInfo = new HashMap<>();
    						final Map<SkillConditionScope, List<NamedParamInfo>> conditionParamInfo = new HashMap<>();
    						for (Node skillNode = listNode.getFirstChild(); skillNode != null; skillNode = skillNode.getNextSibling())
    						{
    							final String skillNodeName = skillNode.getNodeName();
    							switch (skillNodeName.toLowerCase())
    							{
    								case "variable":
    								{
    									attributes = skillNode.getAttributes();
    									final String name = "@" + parseString(attributes, "name");
    									variableValues.put(name, parseValues(skillNode));
    									break;
    								}
    								case "#text":
    								{
    									break;
    								}
    								default:
    								{
    									final EffectScope effectScope = EffectScope.findByXmlNodeName(skillNodeName);
    									if (effectScope != null)
    									{
    										for (Node effectsNode = skillNode.getFirstChild(); effectsNode != null; effectsNode = effectsNode.getNextSibling())
    										{
    											switch (effectsNode.getNodeName().toLowerCase())
    											{
    												case "effect":
    												{
    													effectParamInfo.computeIfAbsent(effectScope, (k) -> new LinkedList<>()).add(parseNamedParamInfo(effectsNode, variableValues));
    													break;
    												}
    											}
    										}
    										break;
    									}
    									final SkillConditionScope skillConditionScope = SkillConditionScope.findByXmlNodeName(skillNodeName);
    									if (skillConditionScope != null)
    									{
    										for (Node conditionNode = skillNode.getFirstChild(); conditionNode != null; conditionNode = conditionNode.getNextSibling())
    										{
    											switch (conditionNode.getNodeName().toLowerCase())
    											{
    												case "condition":
    												{
    													conditionParamInfo.computeIfAbsent(skillConditionScope, (k) -> new LinkedList<>()).add(parseNamedParamInfo(conditionNode, variableValues));
    													break;
    												}
    											}
    										}
    									}
    									else
    									{
    										parseInfo(skillNode, variableValues, skillInfo);
    									}
    									break;
    								}
    							}
    						}
    
    						final int fromLevel = generalSkillInfo.getInt(".fromLevel", 1);
    						final int toLevel = generalSkillInfo.getInt(".toLevel", 0);
    
    						for (int i = fromLevel; i <= toLevel; i++)
    						{
    							levels.computeIfAbsent(i, (k) -> new HashSet<>()).add(0);
    						}
    
    						skillInfo.forEach((level, subLevelMap) ->
    						{
    							if (level == -1)
    							{
    								return;
    							}
    							subLevelMap.forEach((subLevel, statsSet) ->
    							{
    								if (subLevel == -1)
    								{
    									return;
    								}
    								levels.computeIfAbsent(level, (k) -> new HashSet<>()).add(subLevel);
    							});
    						});
    
    						Stream.concat(effectParamInfo.values().stream(), conditionParamInfo.values().stream()).forEach(namedParamInfos ->
    						{
    							namedParamInfos.forEach(namedParamInfo ->
    							{
    								namedParamInfo.getInfo().forEach((level, subLevelMap) ->
    								{
    									if (level == -1)
    									{
    										return;
    									}
    									subLevelMap.forEach((subLevel, statsSet) ->
    									{
    										if (subLevel == -1)
    										{
    											return;
    										}
    										levels.computeIfAbsent(level, (k) -> new HashSet<>()).add(subLevel);
    									});
    								});
    
    								if ((namedParamInfo.getFromLevel() != null) && (namedParamInfo.getToLevel() != null))
    								{
    									for (int i = namedParamInfo.getFromLevel(); i <= namedParamInfo.getToLevel(); i++)
    									{
    										if ((namedParamInfo.getFromSubLevel() != null) && (namedParamInfo.getToSubLevel() != null))
    										{
    											for (int j = namedParamInfo.getFromSubLevel(); j <= namedParamInfo.getToSubLevel(); j++)
    											{
    
    												levels.computeIfAbsent(i, (k) -> new HashSet<>()).add(j);
    											}
    										}
    										else
    										{
    											levels.computeIfAbsent(i, (k) -> new HashSet<>()).add(0);
    										}
    									}
    								}
    							});
    						});
    
    						levels.forEach((level, subLevels) ->
    						{
    							subLevels.forEach(subLevel ->
    							{
    								final StatsSet statsSet = Optional.ofNullable(skillInfo.getOrDefault(level, Collections.emptyMap()).get(subLevel)).orElseGet(StatsSet::new);
    								skillInfo.getOrDefault(level, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(statsSet.getSet()::putIfAbsent);
    								skillInfo.getOrDefault(-1, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(statsSet.getSet()::putIfAbsent);
    								statsSet.set(".level", level);
    								statsSet.set(".subLevel", subLevel);
    								final Skill skill = new Skill(statsSet);
    								forEachNamedParamInfoParam(effectParamInfo, level, subLevel, ((effectScope, params) ->
    								{
    									final String effectName = params.getString(".name");
    									params.remove(".name");
    									try
    									{
    										final Function<StatsSet, AbstractEffect> effectFunction = EffectHandler.getInstance().getHandlerFactory(effectName);
    										if (effectFunction != null)
    										{
    											skill.addEffect(effectScope, effectFunction.apply(params));
    										}
    										else
    										{
    											LOGGER.warning(this.getClass().getSimpleName() + ": Missing effect for Skill Id[" + statsSet.getInt(".id") + "] Level[" + level + "] SubLevel[" + subLevel + "] Effect Scope[" + effectScope + "] Effect Name[" + effectName + "]");
    										}
    									}
    									catch (Exception e)
    									{
    										LOGGER.log(Level.WARNING, this.getClass().getSimpleName() + ": Failed loading effect for Skill Id[" + statsSet.getInt(".id") + "] Level[" + level + "] SubLevel[" + subLevel + "] Effect Scope[" + effectScope + "] Effect Name[" + effectName + "]", e);
    									}
    								}));
    
    								forEachNamedParamInfoParam(conditionParamInfo, level, subLevel, ((skillConditionScope, params) ->
    								{
    									final String conditionName = params.getString(".name");
    									params.remove(".name");
    									try
    									{
    										final Function<StatsSet, ISkillCondition> conditionFunction = SkillConditionHandler.getInstance().getHandlerFactory(conditionName);
    										if (conditionFunction != null)
    										{
    											skill.addCondition(skillConditionScope, conditionFunction.apply(params));
    										}
    										else
    										{
    											LOGGER.warning(this.getClass().getSimpleName() + ": Missing condition for Skill Id[" + statsSet.getInt(".id") + "] Level[" + level + "] SubLevel[" + subLevel + "] Effect Scope[" + skillConditionScope + "] Effect Name[" + conditionName + "]");
    										}
    									}
    									catch (Exception e)
    									{
    										LOGGER.log(Level.WARNING, this.getClass().getSimpleName() + ": Failed loading condition for Skill Id[" + statsSet.getInt(".id") + "] Level[" + level + "] SubLevel[" + subLevel + "] Condition Scope[" + skillConditionScope + "] Condition Name[" + conditionName + "]", e);
    									}
    								}));
    
    								_skills.put(getSkillHashCode(skill), skill);
    								_skillsMaxLevel.merge(skill.getId(), skill.getLevel(), Integer::max);
    								if ((skill.getSubLevel() % 1000) == 1)
    								{
    									EnchantSkillGroupsData.getInstance().addRouteForSkill(skill.getId(), skill.getLevel(), skill.getSubLevel());
    								}
    							});
    						});
    					}
    				}
    			}
    		}
    	}
    
    	private <T> void forEachNamedParamInfoParam(Map<T, List<NamedParamInfo>> paramInfo, int level, int subLevel, BiConsumer<T, StatsSet> consumer)
    	{
    		paramInfo.forEach((scope, namedParamInfos) ->
    		{
    			namedParamInfos.forEach(namedParamInfo ->
    			{
    				if (((namedParamInfo.getFromLevel() == null) && (namedParamInfo.getToLevel() == null)) || ((namedParamInfo.getFromLevel() <= level) && (namedParamInfo.getToLevel() >= level)))
    				{
    					if (((namedParamInfo.getFromSubLevel() == null) && (namedParamInfo.getToSubLevel() == null)) || ((namedParamInfo.getFromSubLevel() <= subLevel) && (namedParamInfo.getToSubLevel() >= subLevel)))
    					{
    						final StatsSet params = Optional.ofNullable(namedParamInfo.getInfo().getOrDefault(level, Collections.emptyMap()).get(subLevel)).orElseGet(StatsSet::new);
    						namedParamInfo.getInfo().getOrDefault(level, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(params.getSet()::putIfAbsent);
    						namedParamInfo.getInfo().getOrDefault(-1, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(params.getSet()::putIfAbsent);
    						params.set(".name", namedParamInfo.getName());
    						consumer.accept(scope, params);
    					}
    				}
    			});
    		});
    	}
    
    	private NamedParamInfo parseNamedParamInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues)
    	{
    		final NamedNodeMap attributes = node.getAttributes();
    		final String name = parseString(attributes, "name");
    		final Integer level = parseInteger(attributes, "level");
    		final Integer fromLevel = parseInteger(attributes, "fromLevel", level);
    		final Integer toLevel = parseInteger(attributes, "toLevel", level);
    		final Integer subLevel = parseInteger(attributes, "subLevel");
    		final Integer fromSubLevel = parseInteger(attributes, "fromSubLevel", subLevel);
    		final Integer toSubLevel = parseInteger(attributes, "toSubLevel", subLevel);
    		final Map<Integer, Map<Integer, StatsSet>> info = new HashMap<>();
    		for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
    		{
    			if (!node.getNodeName().equals("#text"))
    			{
    				parseInfo(node, variableValues, info);
    			}
    		}
    		return new NamedParamInfo(name, fromLevel, toLevel, fromSubLevel, toSubLevel, info);
    	}
    
    	private void parseInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues, Map<Integer, Map<Integer, StatsSet>> info)
    	{
    		Map<Integer, Map<Integer, Object>> values = parseValues(node);
    		final Object generalValue = values.getOrDefault(-1, Collections.emptyMap()).get(-1);
    		if (generalValue != null)
    		{
    			final String stringGeneralValue = String.valueOf(generalValue);
    			if (stringGeneralValue.startsWith("@"))
    			{
    				Map<Integer, Map<Integer, Object>> variableValue = variableValues.get(stringGeneralValue);
    				if (variableValue != null)
    				{
    					values = variableValue;
    				}
    				else
    				{
    					throw new IllegalArgumentException("undefined variable " + stringGeneralValue);
    				}
    			}
    		}
    
    		values.forEach((level, subLevelMap) ->
    		{
    			subLevelMap.forEach((subLevel, value) ->
    			{
    				info.computeIfAbsent(level, (k) -> new HashMap<>()).computeIfAbsent(subLevel, (k) -> new StatsSet()).set(node.getNodeName(), value);
    			});
    		});
    	}
    
    	private Map<Integer, Map<Integer, Object>> parseValues(Node node)
    	{
    		final Map<Integer, Map<Integer, Object>> values = new HashMap<>();
    		Object parsedValue = parseValue(node, true, false, Collections.emptyMap());
    		if (parsedValue != null)
    		{
    			values.computeIfAbsent(-1, (k) -> new HashMap<>()).put(-1, parsedValue);
    		}
    		else
    		{
    			for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
    			{
    				if (node.getNodeName().equalsIgnoreCase("value"))
    				{
    					final NamedNodeMap attributes = node.getAttributes();
    					final Integer level = parseInteger(attributes, "level");
    					if (level != null)
    					{
    						parsedValue = parseValue(node, false, false, Collections.emptyMap());
    						if (parsedValue != null)
    						{
    							final Integer subLevel = parseInteger(attributes, "subLevel", -1);
    							values.computeIfAbsent(level, (k) -> new HashMap<>()).put(subLevel, parsedValue);
    						}
    					}
    					else
    					{
    						final int fromLevel = parseInteger(attributes, "fromLevel");
    						final int toLevel = parseInteger(attributes, "toLevel");
    						final int fromSubLevel = parseInteger(attributes, "fromSubLevel", -1);
    						final int toSubLevel = parseInteger(attributes, "toSubLevel", -1);
    						for (int i = fromLevel; i <= toLevel; i++)
    						{
    							for (int j = fromSubLevel; j <= toSubLevel; j++)
    							{
    								Map<Integer, Object> subValues = values.computeIfAbsent(i, (k) -> new HashMap<>());
    								Map<String, Double> variables = new HashMap<>();
    								variables.put("index", (i - fromLevel) + 1d);
    								variables.put("subIndex", (j - fromSubLevel) + 1d);
    								Object base = values.getOrDefault(i, Collections.emptyMap()).get(-1);
    								if ((base != null) && !(base instanceof StatsSet))
    								{
    									variables.put("base", Double.parseDouble(String.valueOf(base)));
    								}
    								parsedValue = parseValue(node, false, false, variables);
    								if (parsedValue != null)
    								{
    									subValues.put(j, parsedValue);
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    		return values;
    	}
    
    	Object parseValue(Node node, boolean blockValue, boolean parseAttributes, Map<String, Double> variables)
    	{
    		StatsSet statsSet = null;
    		List<Object> list = null;
    		Object text = null;
    		if (parseAttributes && (!node.getNodeName().equals("value") || !blockValue) && (node.getAttributes().getLength() > 0))
    		{
    			statsSet = new StatsSet();
    			parseAttributes(node.getAttributes(), "", statsSet, variables);
    		}
    		for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
    		{
    			final String nodeName = node.getNodeName();
    			switch (node.getNodeName())
    			{
    				case "#text":
    				{
    					final String value = node.getNodeValue().trim();
    					if (!value.isEmpty())
    					{
    						text = parseNodeValue(value, variables);
    					}
    					break;
    				}
    				case "item":
    				{
    					if (list == null)
    					{
    						list = new LinkedList<>();
    					}
    
    					final Object value = parseValue(node, false, true, variables);
    					if (value != null)
    					{
    						list.add(value);
    					}
    					break;
    				}
    				case "value":
    				{
    					if (blockValue)
    					{
    						break;
    					}
    				}
    				default:
    				{
    					final Object value = parseValue(node, false, true, variables);
    					if (value != null)
    					{
    						if (statsSet == null)
    						{
    							statsSet = new StatsSet();
    						}
    
    						statsSet.set(nodeName, value);
    					}
    				}
    			}
    		}
    		if (list != null)
    		{
    			if (text != null)
    			{
    				throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + node + "]");
    			}
    			if (statsSet != null)
    			{
    				statsSet.set(".", list);
    			}
    			else
    			{
    				return list;
    			}
    		}
    		if (text != null)
    		{
    			if (list != null)
    			{
    				throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + node + "]");
    			}
    			if (statsSet != null)
    			{
    				statsSet.set(".", text);
    			}
    			else
    			{
    				return text;
    			}
    		}
    		return statsSet;
    	}
    
    	private void parseAttributes(NamedNodeMap attributes, String prefix, StatsSet statsSet, Map<String, Double> variables)
    	{
    		for (int i = 0; i < attributes.getLength(); i++)
    		{
    			final Node attributeNode = attributes.item(i);
    			statsSet.set(prefix + "." + attributeNode.getNodeName(), parseNodeValue(attributeNode.getNodeValue(), variables));
    		}
    	}
    
    	private void parseAttributes(NamedNodeMap attributes, String prefix, StatsSet statsSet)
    	{
    		parseAttributes(attributes, prefix, statsSet, Collections.emptyMap());
    	}
    
    	private Object parseNodeValue(String value, Map<String, Double> variables)
    	{
    		if (value.startsWith("{") && value.endsWith("}"))
    		{
    			return new ExpressionBuilder(value).variables(variables.keySet()).build().setVariables(variables).evaluate();
    		}
    		return value;
    	}
    
    	public static SkillData getInstance()
    	{
    		return SingletonHolder._instance;
    	}
    
    	private static class SingletonHolder
    	{
    		protected static final SkillData _instance = new SkillData();
    	}
    }

    this is my SkillData and my database and XML are fine

  7. 
    
    <skill id="10010" levels="4" name="Horn Melody">
    <table name="#abnormalLvls"> 1 2 3 4 </table>
    <table name="#pAtk"> 1.17 1.19 1.21 1.23 </table>
    <table name="#pDef"> 1.15 1.15 1.15 1.15 </table>
    <table name="#mAtk"> 1.79 1.83 1.87 1.91 </table>
    <table name="#mDef"> 1.30 1.30 1.30 1.30 </table>
    <table name="#aggroPoints"> 379 457 532 610 </table>
    <table name="#mpConsume"> 28 35 41 47</table>
    <table name="#mpInitialConsume"> 7 9 11 13</table>
    <set name="abnormalLvl" val="#abnormalLvls" />
    <set name="abnormalTime" val="1200" />
    <set name="abnormalType" val="MELODY_HORN" />
    <set name="aggroPoints" val="#aggroPoints" />
    <set name="castRange" val="400" />
    <set name="effectRange" val="900" />
    <set name="hitTime" val="4000" />
    <set name="isMagic" val="1" /> <!-- Magic Skill -->
    <set name="mpConsume" val="#mpConsume" />
    <set name="mpInitialConsume" val="#mpInitialConsume" />
    <set name="operateType" val="A2" />
    <set name="reuseDelay" val="2000" />
    <set name="skillType" val="BUFF" />
    <set name="targetType" val="PARTY_MEMBER" />
    <set name="blockBuffSlot" val="PA_UP;PD_UP;MA_UP;MD_UP;IMPROVE_MA_MD_UP;IMPROVE_PA_PD_UP" />
    <for>
    <effect name="Buff" val="0">
    <mul order="0x30" stat="pAtk" val="#pAtk" />
    <mul order="0x30" stat="pDef" val="#pDef" />
    <mul order="0x30" stat="mAtk" val="#mAtk" />
    <mul order="0x30" stat="mDef" val="#mDef" />
    </effect>
    <effect name="DispelBySlotProbability" noicon="1" val="0">
    <param dispel="PA_UP,9;PD_UP,9;MA_UP,9;MD_UP,9;IMPROVE_MA_MD_UP,9;IMPROVE_PA_PD_UP,9" />
    </effect>
    <effect name="BlockBuffSlot" noicon="1" val="0">
    <param slot="PA_UP;PD_UP;MA_UP;MD_UP;IMPROVE_MA_MD_UP;IMPROVE_PA_PD_UP" />
    </effect>
    </for>
    </skill>

    Yeah, Only adap the part of XML the GOD. 

    thanks for replying me.

  8. Hi all.

    Plz.

    I need help with this. :-

     

    Ver: High Five.

    feb 18, 2017 3:43:00 PM com.l2jserver.gameserver.engines.DocumentBase parse
    GRAVE: Error in file F:\L2\Server\Porn\game\data\stats\skills\custom\10000-10999.xml
    java.lang.NullPointerException
    at com.l2jserver.gameserver.engines.DocumentBase.attachFunc(DocumentBase.java:268)
    at com.l2jserver.gameserver.engines.DocumentBase.parseTemplate(DocumentBase.java:228)
    at com.l2jserver.gameserver.engines.DocumentBase.attachEffect(DocumentBase.java:459)
    at com.l2jserver.gameserver.engines.DocumentBase.parseTemplate(DocumentBase.java:260)
    at com.l2jserver.gameserver.engines.skills.DocumentSkill.parseSkill(DocumentSkill.java:503)
    at com.l2jserver.gameserver.engines.skills.DocumentSkill.parseDocument(DocumentSkill.java:125)
    at com.l2jserver.gameserver.engines.DocumentBase.parse(DocumentBase.java:160)
    at com.l2jserver.gameserver.engines.DocumentEngine.loadSkills(DocumentEngine.java:88)
    at com.l2jserver.gameserver.engines.DocumentEngine.loadAllSkills(DocumentEngine.java:97)
    at com.l2jserver.gameserver.datatables.SkillTable.load(SkillTable.java:60)
    at com.l2jserver.gameserver.datatables.SkillTable.<init>(SkillTable.java:47)
    at com.l2jserver.gameserver.datatables.SkillTable$SingletonHolder.<clinit>(SkillTable.java:222)
    at com.l2jserver.gameserver.datatables.SkillTable.getInstance(SkillTable.java:217)
    at com.l2jserver.gameserver.GameServer.<init>(GameServer.java:241)
    at com.l2jserver.gameserver.GameServer.main(GameServer.java:566)
    

     

  9. L2Character.java	
    
    public Inventory getInventory()
    	{
    		return null;
    	}
    	
    	public boolean destroyItemByItemId(String process, int itemId, long count, L2Object reference, boolean sendMessage)
    	{
    		// Default: NPCs consume virtual items for their skills
    		// TODO: should be logged if even happens.. should be false
    		return true;
    	}
    	
    	public boolean destroyItem(String process, int objectId, long count, L2Object reference, boolean sendMessage)
    	{
    		// Default: NPCs consume virtual items for their skills
    		// TODO: should be logged if even happens.. should be false
    		return true;
    	}
    
    
    

     testing other method 

  10. For example I'm in a Pailaka and I have my scroll weapon updater , I talk with the NPC and look to replace the weapon it does is give me the next leaving the previous there too, at the end of the quest I get all the weapons all of the quest items you use.

     

    As in all the server quest , check the Quest.java and compare it to other projects but I see no difference in corresponding to the themes of the quest line items .

     

     Also try to restart the server and PJ when completing the quest to discard a hypothesis that had but remain in the inventory.

  11. Check the code Quest.java again and I found this.

    	/**
    	 * @return the registered quest items Ids.
    	 */
    	public int[] getRegisteredItemIds()
    	{
    		return questItemIds;
    	}
    
    	/**
    	 * Registers all items that have to be destroyed in case player abort the quest or finish it.
    	 * @param items
    	 */
    	public void RegisteredItemIds(int... items)
    	{
    		questItemIds = items;
    	}
    

    Equally I did what you said to me and it gave to me mistakes in the GameServer with all the quest.

     

    I found this chunk of code also in the quest.java and he is the manager also of eliminating the things of the inventory but nothing.

    	/**
    	 * Remove all quest items associated with this quest from the specified player's inventory.
    	 * @param player the player whose quest items to remove
    	 */
    	public void removeRegisteredQuestItems(L2PcInstance player)
    	{
    		takeItems(player, -1, questItemIds);
    	}
    

    sorry my bad ingles.

  12. I was checking everything what you have said to me and I don't find anything bad.

     

    Check the quest.java and it has his lines well to my seem.
    /**
    	 * Registers all items that have to be destroyed in case player abort the quest or finish it.
    	 * @param items
    	 */
    	public void registerQuestItems(int... items)
    	{
    		questItemIds = items;
    	}
    

     

    I leave the whole complete code for if someone vee something that I ignore. :-\

     

    http://pastebin.com/qAL42YCL

     

    sorry my bad ingles.

     

×
×
  • Create New...