Jump to content

Recommended Posts

Posted (edited)
On 5/3/2021 at 2:29 PM, Porthos said:

Cherish threw a fit because he wanted credits for 4 lines of code, not to mention he was continuously derailing discussions offtopic because he was going into opinionated tangents about random things. The credits thing was the worst fit ive seen him throw and im not surprised he got booted from the discord for that.

L2JServer has certain criteria about giving credits which you can read here: https://www.l2jserver.com/forum/viewtopic.php?f=29&t=30453&p=182222#p182580

Based on these rules did he deserve credits other than in the commit comment? That's for each one of you to decide.

 

Also theres no randoms taking over L2JServer, if anything the new team members have brought the pack back to life. Theres a lot of cool shit coming like complete High Five Skills with proper handlers and a targeting rework that both will address a lot of issues.

 

Generally i see a lot of ego from people involved in the l2j scene, this needs to stop unless you like to be paying hundreds of dollars or euros for subpar work.


Here you go. You can change it into double and push to main branch.
I have already asked for more appropriate way to present my work.

What if is ego? Say I've "learned" java, got familiar with project enough to fix a broken drop calc, present for many years, with close to none assistance and I have shared it, if not for money, what's left?

If you can not appreciate my effort to give it few bytes of credits that is not being compiled, then users should apply patch manually on demand, found here.

After all, this is a custom feature for a custom drop on a custom rate and L2JServer focuses on "Retail" behavior and code does not take part of main branch.
 

 

 

/*
 * Copyright © 2004-2021 L2J Server
 *
 * This file is part of L2J Server.
 *
 * L2J Server 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.
 *
 * L2J Server 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 com.l2jserver.gameserver.model.drops.strategy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.l2jserver.commons.util.Rnd;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.drops.GroupedGeneralDropItem;
import com.l2jserver.gameserver.model.drops.IDropItem;
import com.l2jserver.gameserver.model.holders.ItemHolder;

/**
 *@author Battlecruiser, Cherish
 */

public interface IGroupedItemDropCalculationStrategy {
	/**
	 * L2J Server most percise drop calculation when group chances are over one houdred percent.
	 */
	IGroupedItemDropCalculationStrategy DEFAULT_STRATEGY = new IGroupedItemDropCalculationStrategy() {
		private final Map<GroupedGeneralDropItem, GeneralDropItem> singleItemCache = new ConcurrentHashMap<>();
		
		private GeneralDropItem getSingleItem(GroupedGeneralDropItem dropItem) {
			final GeneralDropItem item1 = dropItem.getItems().iterator().next();
			singleItemCache.putIfAbsent(dropItem, new GeneralDropItem(item1.getItemId(), item1.getMin(), item1.getMax(), (item1.getChance() * dropItem.getChance()) / 100, //
				item1.getAmountStrategy(), item1.getChanceStrategy(), dropItem.getPreciseStrategy(), dropItem.getKillerChanceModifierStrategy(), item1.getDropCalculationStrategy()));
			return singleItemCache.get(dropItem);
		}
		
		@Override
		public List<ItemHolder> calculateDrops(GroupedGeneralDropItem dropItem, L2Character victim, L2Character killer) {
			if (dropItem.getItems().size() == 1) {
				return getSingleItem(dropItem).calculateDrops(victim, killer);
			}
			
			GroupedGeneralDropItem normalized = dropItem.normalizeMe(victim, killer);
			if (normalized.getChance() > (Rnd.nextDouble() * 100)) {
				final double random = (Rnd.nextDouble() * 100);
				double totalChance = 0;
				for (GeneralDropItem item2 : normalized.getItems()) {
					totalChance += item2.getChance();
					if (totalChance > random) {
						int amountMultiply = 1;
						if (dropItem.isPreciseCalculated() && normalized.getChance() > 100) {
							int MostPreciseFormula = 0;
							MostPreciseFormula += item2.getChance() * (normalized.getChance() / 100);
							if (MostPreciseFormula >= 100) {
								amountMultiply = (int) MostPreciseFormula / 100;
								if ((MostPreciseFormula % 100) > (Rnd.nextDouble() * 100)) {
									amountMultiply++;
								}
							}
						}	
						return Collections.singletonList(new ItemHolder(item2.getItemId(), Rnd.get(item2.getMin(victim), item2.getMax(victim)) * amountMultiply));
					}
				}
			}
			return null;
		}
	};
	
	/**
	 * This strategy calculates a group's drop by calculating drops of its individual items and merging its results.
	 */
	IGroupedItemDropCalculationStrategy DISBAND_GROUP = (item, victim, killer) -> {
		List<ItemHolder> dropped = new ArrayList<>();
		for (IDropItem dropItem : item.extractMe()) {
			dropped.addAll(dropItem.calculateDrops(victim, killer));
		}
		return dropped.isEmpty() ? null : dropped;
	};
	
	/**
	 * This strategy when group has precise calculation rolls multiple times over group to determine drops when group's chance raises over 100% instead of just multiplying the dropped item's amount. Thus it can produce different items from group at once.
	 */
	IGroupedItemDropCalculationStrategy PRECISE_MULTIPLE_GROUP_ROLLS = (item, victim, killer) -> {
		if (!item.isPreciseCalculated()) {
			// if item hasn't precise calculation there's no change from DEFAULT_STRATEGY
			return DEFAULT_STRATEGY.calculateDrops(item, victim, victim);
		}
		GroupedGeneralDropItem newItem = new GroupedGeneralDropItem(item.getChance(), DEFAULT_STRATEGY, item.getKillerChanceModifierStrategy(), IPreciseDeterminationStrategy.NEVER);
		newItem.setItems(item.getItems());
		GroupedGeneralDropItem normalized = newItem.normalizeMe(victim, killer);
		// Let's determine the number of rolls.
		int rolls = (int) (normalized.getChance() / 100);
		if ((Rnd.nextDouble() * 100) < (normalized.getChance() % 100)) {
			rolls++;
		}
		List<ItemHolder> dropped = new ArrayList<>(rolls);
		for (int i = 0; i < rolls; i++) {
			// As further normalizing on already normalized drop group does nothing, we can just pass the calculation to DEFAULT_STRATEGY with precise calculation disabled as we handle it.
			dropped.addAll(normalized.calculateDrops(victim, killer));
		}
		return dropped.isEmpty() ? null : dropped;
	};
	
	List<ItemHolder> calculateDrops(GroupedGeneralDropItem item, L2Character victim, L2Character killer);
}

 

Edited by Cherish
  • 1 year later...
Posted (edited)

The people that are killing L2JServer must be publicly exposed. 😄
I've shared with you Improved Crystal Caverns and Precision Formula.
In return all I received was disrespect and humiliation?
Well, that was the last of me for the true open source L2JServer.

Have fun copycats!

 

Edited by Cherish
  • 7 months later...
Posted

Hi people. Does anybody solved this formula?. I found that this is not exact with drops groups. I have for example 100% drop on a mob but is not 100% really. If i add a item drop outside of any group it's drops 100%

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • ⚔️ The Grand Opening Has Arrived! ⚔️ In just a few hours the gate to the eternal battlefield will be open and the war between Order and Chaos will be set once again ! Its time to claim your destiny 🔥 👉 Register now and join the fight today! 🌐 https://l2ovc.com register now : https://l2ovc.com
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to you the current list of promotions and special offers for purchasing our products and services: 1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to you the current list of promotions and special offers for purchasing our products and services: 1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to you the current list of promotions and special offers for purchasing our products and services: 1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock