Jump to content

Question

Posted

Hello guys, i have L2day event script and try to configure and change it, but don't know now how make 2 rewards :) 1 item 100% and other by chance...

When i collect word "Chronicle" or "Lineage II" and pres to npc i wanna get 1 item 100% (unique item "Letter Collector's Gift") and + one item from the list...

 

package l2f.gameserver.scripts.events.l2day;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import l2f.gameserver.model.reward.RewardData;

public class l2day extends LettersCollection
{
	static
	{
		_name = "l2day";
		_msgStarted = "scripts.events.l2day.AnnounceEventStarted";
		_msgEnded = "scripts.events.l2day.AnnounceEventStoped";

		EVENT_MANAGERS = new int[][] {{ 83720, 149720, -3430, 49151 }};

		_words.put("LineageII", new Integer[][] { { L, 1 }, { I, 1 }, { N, 1 }, { E, 2 }, { A, 1 }, { G, 1 }, { II, 1 } });
		_rewards.put("LineageII", new RewardData[] {
			
				// Reward list
				new RewardData(0, 1, 1, 1000000),		//	100% 
				new RewardData(0, 1, 1, 750000),		//	75%
				new RewardData(0, 1, 1, 500000),		//	50%
				new RewardData(0, 1, 1, 250000),		//	25%
				new RewardData(0, 1, 1, 100000),		//	10%
				new RewardData(0, 1, 1, 50000),			//	5%
				new RewardData(0, 1, 1, 5000),			//	0.5%
				new RewardData(0, 1, 1, 1000),			//	0.1%
				new RewardData(0, 1, 1, 100), });		//	0.01%
		
		
		_words.put("Chronicle", new Integer[][] { { C, 2 }, { H, 1 }, { R, 1 }, { O, 1 }, { N, 1 }, { I, 1 }, { L, 1 }, { E, 1 } });
		_rewards.put("Chronicle", new RewardData[] {
			
				// Reward list
				new RewardData(0, 1, 1, 1000000),		//	100% 
				new RewardData(0, 1, 1, 750000),		//	75%
				new RewardData(0, 1, 1, 500000),		//	50%
				new RewardData(0, 1, 1, 250000),		//	25%
				new RewardData(0, 1, 1, 100000),		//	10%
				new RewardData(0, 1, 1, 50000),			//	5%
				new RewardData(0, 1, 1, 5000),			//	0.5%
				new RewardData(0, 1, 1, 1000),			//	0.1%
				new RewardData(0, 1, 1, 100), });		//	0.01%


		final int DROP_MULT = 3;

		Map<Integer, Integer> temp = new HashMap <Integer, Integer>();
		for(Integer[][] ii : _words.values())
			for(Integer[] i : ii)
			{
				Integer curr = temp.get(i[0]);
				if(curr == null)
					temp.put(i[0], i[1]);
				else
					temp.put(i[0], curr + i[1]);
			}
		letters = new int[temp.size()][2];
		int i = 0;
		for(Entry<Integer, Integer> e : temp.entrySet())
			letters[i++] = new int[] { e.getKey(), e.getValue() * DROP_MULT };
	}
}

4 answers to this question

Recommended Posts

  • 0
Posted

Find where it gives the random rewards and put a reward 100%

What is inside rewarddata.java?

package l2f.gameserver.model.reward;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;

import l2f.commons.math.SafeMath;
import l2f.commons.util.Rnd;
import l2f.gameserver.Config;
import l2f.gameserver.data.xml.holder.ItemHolder;
import l2f.gameserver.model.Player;
import l2f.gameserver.templates.item.ItemTemplate;

public class RewardData implements Cloneable
{
	private final ItemTemplate _item;
	private boolean _notRate = false; // Rate things do not apply to
	
	private long _mindrop;
	private long _maxdrop;
	private double _chance;
	private double _chanceInGroup;
	
	public RewardData(int itemId)
	{
		_item = ItemHolder.getInstance().getTemplate(itemId);
		if (_item.isArrow() // Boom not Rate
			|| (Config.NO_RATE_EQUIPMENT && _item.isEquipment()) // Switched rate equip
			|| (Config.NO_RATE_KEY_MATERIAL && _item.isKeyMatherial()) // Switched rate key materials
			|| (Config.NO_RATE_RECIPES && _item.isRecipe()) // Switched rate recipe
			|| ArrayUtils.contains(Config.NO_RATE_ITEMS, itemId)) // individaulnaya switchable rate for a list of items
			_notRate = true;
	}
	
	public RewardData(int itemId, long min, long max, double chance)
	{
		this(itemId);
		_mindrop = min;
		_maxdrop = max;
		_chance = chance;
	}
	
	public boolean notRate()
	{
		return _notRate;
	}
	
	public void setNotRate(boolean notRate)
	{
		_notRate = notRate;
	}
	
	public int getItemId()
	{
		return _item.getItemId();
	}
	
	public ItemTemplate getItem()
	{
		return _item;
	}
	
	public long getMinDrop()
	{
		return _mindrop;
	}
	
	public long getMaxDrop()
	{
		return _maxdrop;
	}
	
	public double getChance()
	{
		return _chance;
	}
	
	public void setMinDrop(long mindrop)
	{
		_mindrop = mindrop;
	}
	
	public void setMaxDrop(long maxdrop)
	{
		_maxdrop = maxdrop;
	}
	
	public void setChance(double chance)
	{
		_chance = chance;
	}
	
	public void setChanceInGroup(double chance)
	{
		_chanceInGroup = chance;
	}
	
	public double getChanceInGroup()
	{
		return _chanceInGroup;
	}
	
	@Override
	public String toString()
	{
		return "ItemID: " + getItem() + " Min: " + getMinDrop() + " Max: " + getMaxDrop() + " Chance: " + (getChance() / 10000.0) + "%";
	}
	
	@Override
	public RewardData clone()
	{
		return new RewardData(getItemId(), getMinDrop(), getMaxDrop(), getChance());
	}
	
	@Override
	public boolean equals(Object o)
	{
		if (o instanceof RewardData)
		{
			final RewardData drop = (RewardData) o;
			return drop.getItemId() == getItemId();
		}
		return false;
	}
	
	/**
	 * Counting the drop rate of this particular thing Used in the opening event, and some special arrangements
	 * @param Player the player (it affects the chance of a bonus)
	 * @param Mod (just a chance factor)
	 * @return Information about things that fell
	 */
	public List<RewardItem> roll(Player player, double mod)
	{
		double rate = 1.0;
		if (_item.isAdena())
			rate = Config.RATE_DROP_ADENA * player.getRateAdena();
		else if (_item.isEpolets())
			rate = Config.RATE_CHANCE_DROP_EPOLET * player.getRateEpolets();
		else
			rate = Config.RATE_DROP_ITEMS * (player != null ? player.getRateItems() : 1.);
		
		return roll(rate * mod);
	}
	
	/**
	 * Counting the drop rate of this particular thing Used in the opening event, and some special arrangements
	 * @param Rate multiplier quantity
	 * @return Information about things that fell
	 */
	public List<RewardItem> roll(double rate)
	{
		final double mult = Math.ceil(rate);
		
		final List<RewardItem> ret = new ArrayList<>(1);
		RewardItem t = null;
		long count;
		for (int n = 0; n < mult; n++)
			if (Rnd.get(RewardList.MAX_CHANCE) <= (_chance * Math.min(rate - n, 1.0)))
			{
				if (getMinDrop() >= getMaxDrop())
					count = getMinDrop();
				else
					count = Rnd.get(getMinDrop(), getMaxDrop());
				
				if (t == null)
				{
					ret.add(t = new RewardItem(_item.getItemId()));
					t.count = count;
				}
				else
					t.count = SafeMath.addAndLimit(t.count, count);
			}
		
		return ret;
	}
}
}
  • 0
Posted

 

package l2f.gameserver.model.reward;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;

import l2f.commons.math.SafeMath;
import l2f.commons.util.Rnd;
import l2f.gameserver.Config;
import l2f.gameserver.data.xml.holder.ItemHolder;
import l2f.gameserver.model.Player;
import l2f.gameserver.templates.item.ItemTemplate;

public class RewardData implements Cloneable
{
	private final ItemTemplate _item;
	private boolean _notRate = false; // Rate things do not apply to
	
	private long _mindrop;
	private long _maxdrop;
	private double _chance;
	private double _chanceInGroup;
	
	public RewardData(int itemId)
	{
		_item = ItemHolder.getInstance().getTemplate(itemId);
		if (_item.isArrow() // Boom not Rate
			|| (Config.NO_RATE_EQUIPMENT && _item.isEquipment()) // Switched rate equip
			|| (Config.NO_RATE_KEY_MATERIAL && _item.isKeyMatherial()) // Switched rate key materials
			|| (Config.NO_RATE_RECIPES && _item.isRecipe()) // Switched rate recipe
			|| ArrayUtils.contains(Config.NO_RATE_ITEMS, itemId)) // individaulnaya switchable rate for a list of items
			_notRate = true;
	}
	
	public RewardData(int itemId, long min, long max, double chance)
	{
		this(itemId);
		_mindrop = min;
		_maxdrop = max;
		_chance = chance;
	}
	
	public boolean notRate()
	{
		return _notRate;
	}
	
	public void setNotRate(boolean notRate)
	{
		_notRate = notRate;
	}
	
	public int getItemId()
	{
		return _item.getItemId();
	}
	
	public ItemTemplate getItem()
	{
		return _item;
	}
	
	public long getMinDrop()
	{
		return _mindrop;
	}
	
	public long getMaxDrop()
	{
		return _maxdrop;
	}
	
	public double getChance()
	{
		return _chance;
	}
	
	public void setMinDrop(long mindrop)
	{
		_mindrop = mindrop;
	}
	
	public void setMaxDrop(long maxdrop)
	{
		_maxdrop = maxdrop;
	}
	
	public void setChance(double chance)
	{
		_chance = chance;
	}
	
	public void setChanceInGroup(double chance)
	{
		_chanceInGroup = chance;
	}
	
	public double getChanceInGroup()
	{
		return _chanceInGroup;
	}
	
	@Override
	public String toString()
	{
		return "ItemID: " + getItem() + " Min: " + getMinDrop() + " Max: " + getMaxDrop() + " Chance: " + (getChance() / 10000.0) + "%";
	}
	
	@Override
	public RewardData clone()
	{
		return new RewardData(getItemId(), getMinDrop(), getMaxDrop(), getChance());
	}
	
	@Override
	public boolean equals(Object o)
	{
		if (o instanceof RewardData)
		{
			final RewardData drop = (RewardData) o;
			return drop.getItemId() == getItemId();
		}
		return false;
	}
	
	/**
	 * Counting the drop rate of this particular thing Used in the opening event, and some special arrangements
	 * @param Player the player (it affects the chance of a bonus)
	 * @param Mod (just a chance factor)
	 * @return Information about things that fell
	 */
	public List<RewardItem> roll(Player player, double mod)
	{
		double rate = 1.0;
		if (_item.isAdena())
			rate = Config.RATE_DROP_ADENA * player.getRateAdena();
		else if (_item.isEpolets())
			rate = Config.RATE_CHANCE_DROP_EPOLET * player.getRateEpolets();
		else
			rate = Config.RATE_DROP_ITEMS * (player != null ? player.getRateItems() : 1.);
		
		return roll(rate * mod);
	}
	
	/**
	 * Counting the drop rate of this particular thing Used in the opening event, and some special arrangements
	 * @param Rate multiplier quantity
	 * @return Information about things that fell
	 */
	public List<RewardItem> roll(double rate)
	{
		final double mult = Math.ceil(rate);
		
		final List<RewardItem> ret = new ArrayList<>(1);
		RewardItem t = null;
		long count;
		for (int n = 0; n < mult; n++)
			if (Rnd.get(RewardList.MAX_CHANCE) <= (_chance * Math.min(rate - n, 1.0)))
			{
				if (getMinDrop() >= getMaxDrop())
					count = getMinDrop();
				else
					count = Rnd.get(getMinDrop(), getMaxDrop());
				
				if (t == null)
				{
					ret.add(t = new RewardItem(_item.getItemId()));
					t.count = count;
				}
				else
					t.count = SafeMath.addAndLimit(t.count, count);
			}
		
		return ret;
	}
}
}
As i can remember now this works with npc find the bypass from this npc please and paste here..
  • 0
Posted (edited)

As i can remember now this works with npc find the bypass from this npc please and paste here..

 

You talk about Event Manager npc? "EVENT_MANAGERS = new int[][] {{ 83720, 149720, -3430, 49151 }};"

 

Maybe its something here?

package l2f.gameserver.scripts.events.l2day;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import l2f.commons.util.Rnd;
import l2f.gameserver.Announcements;
import l2f.gameserver.Config;
import l2f.gameserver.cache.Msg;
import l2f.gameserver.listener.actor.OnDeathListener;
import l2f.gameserver.listener.actor.player.OnPlayerEnterListener;
import l2f.gameserver.model.Creature;
import l2f.gameserver.model.Player;
import l2f.gameserver.model.SimpleSpawner;
import l2f.gameserver.model.actor.listener.CharListenerList;
import l2f.gameserver.model.instances.NpcInstance;
import l2f.gameserver.model.reward.RewardData;
import l2f.gameserver.scripts.Functions;
import l2f.gameserver.scripts.ScriptFile;
import l2f.gameserver.templates.npc.NpcTemplate;

public class LettersCollection extends Functions implements ScriptFile, OnDeathListener, OnPlayerEnterListener
{
	private static final Logger _log = LoggerFactory.getLogger(LettersCollection.class);
	// Переменные, определять
	protected static boolean _active;
	protected static String _name;
	protected static int[][] letters;
	protected static int EVENT_MANAGERS[][] = null;
	protected static String _msgStarted;
	protected static String _msgEnded;
	
	// Буквы, статика
	protected static int A = 3875;
	protected static int C = 3876;
	protected static int E = 3877;
	protected static int F = 3878;
	protected static int G = 3879;
	protected static int H = 3880;
	protected static int I = 3881;
	protected static int L = 3882;
	protected static int N = 3883;
	protected static int O = 3884;
	protected static int R = 3885;
	protected static int S = 3886;
	protected static int T = 3887;
	protected static int II = 3888;
	protected static int Y = 13417;
	protected static int _5 = 13418;
	
	protected static int EVENT_MANAGER_ID = 31230;
	
	// Контейнеры, не трогать
	protected static Map<String, Integer[][]> _words = new HashMap<>();
	protected static Map<String, RewardData[]> _rewards = new HashMap<>();
	protected static List<SimpleSpawner> _spawns = new ArrayList<>();
	
	@Override
	public void onLoad()
	{
		if (isActive())
		{
			CharListenerList.addGlobal(this);
			if (!Config.EVENT_LETTER_COLLECTION)
				return;
			
			_active = true;
			spawnEventManagers();
			_log.info("Loaded Event: " + _name + " [state: activated]");
		}
		else
			_log.info("Loaded Event: " + _name + " [state: deactivated]");
	}
	
	/**
	 * Читает статус эвента из базы.
	 */
	protected static boolean isActive()
	{
		return IsActive(_name);
	}
	
	/**
	 * Спавнит эвент менеджеров
	 */
	protected void spawnEventManagers()
	{
		SpawnNPCs(EVENT_MANAGER_ID, EVENT_MANAGERS, _spawns);
	}
	
	/**
	 * Удаляет спавн эвент менеджеров
	 */
	protected void unSpawnEventManagers()
	{
		deSpawnNPCs(_spawns);
	}
	
	@Override
	public void onReload()
	{
		unSpawnEventManagers();
	}
	
	@Override
	public void onShutdown()
	{
		unSpawnEventManagers();
	}
	
	/**
	 * Обработчик смерти мобов, управляющий эвентовым дропом
	 */
	@Override
	public void onDeath(Creature cha, Creature killer)
	{
		if (_active && SimpleCheckDrop(cha, killer))
		{
			final int[] letter = letters[Rnd.get(letters.length)];
			if (Rnd.chance(letter[1] * Config.EVENT_L2DAY_LETTER_CHANCE * ((NpcTemplate) cha.getTemplate()).rateHp))
				((NpcInstance) cha).dropItem(killer.getPlayer(), letter[0], 1);
		}
	}
	
	/**
	 * Запускает эвент
	 */
	public void startEvent()
	{
		final Player player = getSelf();
		if (!player.getPlayerAccess().IsEventGm)
			return;
		
		if (SetActive(_name, true))
		{
			spawnEventManagers();
			System.out.println("Event '" + _name + "' started.");
			Announcements.getInstance().announceByCustomMessage(_msgStarted, null);
		}
		else
			player.sendMessage("Event '" + _name + "' already started.");
		
		_active = true;
		
		show("admin/events/events.htm", player);
	}
	
	/**
	 * Останавливает эвент
	 */
	public void stopEvent()
	{
		final Player player = getSelf();
		if (!player.getPlayerAccess().IsEventGm)
			return;
		if (SetActive(_name, false))
		{
			unSpawnEventManagers();
			System.out.println("Event '" + _name + "' stopped.");
			Announcements.getInstance().announceByCustomMessage(_msgEnded, null);
		}
		else
			player.sendMessage("Event '" + _name + "' not started.");
		
		_active = false;
		
		show("admin/events/events.htm", player);
	}
	
	/**
	 * Обмен эвентовых вещей, где var[0] - слово.
	 */
	public void exchange(String[] var)
	{
		final Player player = getSelf();
		
		if (!player.isQuestContinuationPossible(true))
			return;
		
		if (!NpcInstance.canBypassCheck(player, player.getLastNpc()))
			return;
		
		final Integer[][] mss = _words.get(var[0]);
		
		for (final Integer[] l : mss)
			if (getItemCount(player, l[0]) < l[1])
			{
				player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS);
				return;
			}
		
		for (final Integer[] l : mss)
			removeItem(player, l[0], l[1]);
		
		final RewardData[] rewards = _rewards.get(var[0]);
		int sum = 0;
		for (final RewardData r : rewards)
			sum += r.getChance();
		final int random = Rnd.get(sum);
		sum = 0;
		for (final RewardData r : rewards)
		{
			sum += r.getChance();
			if (sum > random)
			{
				addItem(player, r.getItemId(), Rnd.get(r.getMinDrop(), r.getMaxDrop()));
				return;
			}
		}
	}
	
	@Override
	public void onPlayerEnter(Player player)
	{
	}
	
	public String DialogAppend_31230(Integer val)
	{
		if (!_active)
			return "";
		
		final StringBuilder append = new StringBuilder("<br><br>");
		for (final String word : _words.keySet())
			append.append("[scripts_").append(getClass().getName()).append(":exchange ").append(word).append("|").append(word).append("]<br1>");
		
		return append.toString();
	}
}
Edited by Celsas

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • ⭐⭐⭐⭐⭐L2Lusty 50x [Essence - High Five] Start 08 February⭐⭐⭐⭐⭐  L2Lusty Essence - High Five 50x Website: https://l2lusty.online/ Starts on 08/02/2025 16:00 London Time Rates: XP 50X, Adena 20X, Spoil 20X, Drop 20X, Max enchant +16 with 50% normal and 60% blessed, Chaos Event whit 3x Lcoins Drop 24h Website:  https://l2lusty.online/
    • Hi, I inviting you to join L2Einhovant server, lets give them chanse. It's x1 Classic with some bonus futures, no duals box, no wipes, buffs stores and etc. Grow up by litle steps together with the server population.   🔥 Why L2Einhovant? ✅ Authentic Classic Gameplay – No dual box, all classes inportant, no auto farm. ✅ Hardcore x1 Rates – A true test of your gameplay skill, level up stages. ✅ Active Community & Fair Administration – A server built for passionate players. ✅ Long-Term Stability – Grow your character in a world that lasts.   Gather your allies, sharpen your weapons, and prepare for an unforgettable journey. Join to our comunity now and prepare for start.   Open beta: 1th February. Grand opening: 7th February, 20:00 UTC+2.   🔗 Discord: https://discord.gg/zfKd4tU9N2
    • ElmoreLab Harbor - Eternal C1 x1: ✅ https://harbor.elmorelab.com ElmoreLab Harbor - Eternal C1 x1 - is an exclusive server of the Eternal C1 chronicles from the top project ElmoreLab Harbor.   A unique server of its kind, on which everyone will have maximum pleasure, such as oldschool players who dream of nostalgia and to feel the warmest and classic C1 chronicles, as well as experienced players who are tired of thousands unbalanced servers of late chronicles. Due to the professional corrections of the balance system and the HONEST gameplay system - on this server, EVERY player will feel like in their own, warm and cozy Harbor C1. Let's return to the origins of L2 - back to 2004 in C1! ❤️   ⭐ Server characteristics:   STRICTLY 1 window, NO BOXES Bans for RMT and bots/cheats No donations with benefits Unique and high-quality PTS-build from Master Toma Professional corrections and full class-balance Reworked economy and closed all abuses Improved animations and all aspects of the game Exclusive HD-client with high-quality textures Experienced administration and management Fixed all bugs, geodata, exploits and holes Maximum sociality due to the 1-box system Discovering, exploring and researching Big online International server Nostalgia and oldschool-feelings   Rates: x1 Server start: 14.02.2025   The server is at the final stages of development and preparation for release. Information on the server will be updated, soon the patchnotes and changes/edits will be posted. Don't miss the legendary and epic experience on the best server in the last 20 years! ❤️ Join our C1-forum with a lot of information about server and active discussions.   ⭐ Website: https://harbor.elmorelab.com   ✅ Forum: https://forum-harbor.elmorelab.com   💥 Telegram: https://t.me/l2harbor https://t.me/l2harbor_chat   ⚡ Discord: https://discord.gg/harborelmorelab
    • yeah ok, if you say what is fuctional 100% i can't say something different 😛  but if someone find hard to compile it or get vs and all that things i have here one more simple way here to put overlay in your own server or to change your window name with few money.
  • Topics

×
×
  • Create New...