Jump to content
  • 0

[Help] Edit Compressed soulshot pack.


Question

Posted

I was going to try to create my own compressed pack to open into a list of possible items. I didn't know where to start so I thought I would edit some that already exist. I wasn't really sure how to do this so I thought I would post what I got to see if I'm on the right track. Don't want to mess up the file and my source code.

Current code from CompShotPacks.java

public void useItem(L2PlayableInstance playable, L2ItemInstance item)

{

if (!(playable instanceof L2PcInstance))

return;

L2PcInstance activeChar = (L2PcInstance) playable;

 

int itemId = item.getItemId();

int itemToCreateId = 0;

int amount = 0; // default regular pack

 

if (itemId >= 5134 && itemId <= 5139) // SS

{

if (itemId == 5134) // No Grade

itemToCreateId = 1835;

else

itemToCreateId = itemId - 3672;

 

amount = 300;

}

else if (itemId >= 5250 && itemId <= 5255) // Greater SS

{

if (itemId == 5250) // No Grade

itemToCreateId = 1835;

else

itemToCreateId = itemId - 3788;

 

amount = 1000;

}

else if (itemId >= 5140 && itemId <= 5145) // SpS

{

}

else if (itemId >= 5256 && itemId <= 5261) // Greater SpS

{

}

What I want to do is add a list of possible items that have a random chance to open and a random min-max amount. This is my attempt I don't know the code to do random min-max amount yet.

public void useItem(L2PlayableInstance playable, L2ItemInstance item)

{

if (!(playable instanceof L2PcInstance))

return;

L2PcInstance activeChar = (L2PcInstance) playable;

 

int itemId = item.getItemId();

int itemToCreateId = 0;

int amount = 0; // default regular pack

 

if (itemId >= 5134 && itemId <= 5139) // SS

{

if (itemId == 5134) // No Grade

                          (Rnd.get(100) > 20)

itemToCreateId = 7580;

amount = 1;

                          (Rnd.get(100) > 30)

itemToCreateId = 6847;

amount = 1;

}

Hopefully it would open and give you a 20% chance to recieve 1 of item 7580 and 30% chance to recieve 1 of 6847. This pack doesn't need random amount because its for recipes.

But if I edit the next pack I want it to open up into mats then I would need the random min-max amount. Which I don't know how to add so I can set the min amount and max amount right there.

Example:

Open pack,

(Rnd.get(100) >20)

itemToCreateId = 57;

(Rnd.get(3 - 5) (Get Min 3 or max of 5)

I don't know what the min max is so I just took a guess.

 

 

 

15 answers to this question

Recommended Posts

  • 0
Posted

I am glad to see that you tried to do something and you didn't come without any efforts.

The easiest method is to create a integer and define it with Rnd values.

 

So We will have

public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
	if (!(playable instanceof L2PcInstance))
		return;
	L2PcInstance activeChar = (L2PcInstance) playable;

	int itemId = item.getItemId();
	int itemToCreateId = 0;

	boolean chance20 = 20 > Rnd.get(100), chance30 = 30 > Rnd.get(100);
	int amount = 0;

	if (itemId >= 5134 && itemId <= 5139) // SS
	{
		if (itemId == 5134 && chance20) // No Grade
		{
			itemToCreateId = 7580;
			amount = Rnd.get(3, 5);
		}
		if (itemId == 5135 && chance30)
		{
			itemToCreateId = 6847;
			amount = Rnd.get(3, 5);
		}
	}
}

 

If you have more than 2-3 items make a private method to get the chance ...

 

-Cheers

  • 0
Posted

Yea I will be having lots more items to have a chance to get when the pack opens. So I will need to try to find that out. Thank you for your help.

  • 0
Posted

Yea I will be having lots more items to have a chance to get when the pack opens. So I will need to try to find that out. Thank you for your help.

I'm home right now, Let me code it for ya ..

 

public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
	if (!(playable instanceof L2PcInstance))
		return;
	L2PcInstance activeChar = (L2PcInstance) playable;

	int itemId = item.getItemId();
	int itemToCreateId = 0, amount = 0;

	if (itemId >= 5134 && itemId <= 5139) // SS
	{
		if (itemId == 5134 && getChance(20)) // No Grade
		{
			itemToCreateId = 7580;
			amount = Rnd.get(3, 5);
		}
		if (itemId == 5135 && getChance(30))
		{
			itemToCreateId = 6847;
			amount = Rnd.get(3, 5);
		}
	}
}

 

private boolean getChance(int i)
{
return i > Rnd.get(100);
}

  • 0
Posted

Thank you, This is the whole .java and I wanted to make sure I entered it correct. Because Eclipse is giving me an error saying Rnd cannot be resolved.

public class CompShotPacks implements IItemHandler

{

private static final int[] ITEM_IDS =

{

5134, 5135, 5136, 5137, 5138, 5139, /**/5250, 5251, 5252, 5253, 5254, 5255 // SS

// 5140, 5141, 5142, 5143, 5144, 5145, /**/ 5256, 5257, 5258, 5259, 5260, 5261, // SpS

// 5146, 5147, 5148, 5149, 5150, 5151, /**/ 5262, 5263, 5264, 5265, 5266, 5267 // BSpS

};

private boolean getChance(int i)

{

return i > Rnd.get(100);

}

 

public void useItem(L2PlayableInstance playable, L2ItemInstance item)

{

if (!(playable instanceof L2PcInstance))

return;

L2PcInstance activeChar = (L2PcInstance) playable;

 

int itemId = item.getItemId();

int itemToCreateId = 0;

 

boolean chance20 = 20 > Rnd.get(100), chance30 = 30 > Rnd.get(100);

int amount = 0; // default regular pack

 

if (itemId >= 5134 && itemId <= 5139) // SS

{

if (itemId == 5134 && chance20) // No Grade

itemToCreateId = 7580;

            amount = Rnd.get(1, 2);

}

if (itemId == 5135 && chance30)

{

itemToCreateId = 6847;

amount = Rnd.get(1, 2);

}

activeChar.getInventory().destroyItem("Extract", item, activeChar, null);

activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);

 

SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);

sm.addItemName(itemToCreateId);

sm.addNumber(amount);

activeChar.sendPacket(sm);

 

ItemList playerUI = new ItemList(activeChar, false);

activeChar.sendPacket(playerUI);

}

 

public int[] getItemIds()

{

return ITEM_IDS;

}

}

  • 0
Posted

Sorry for double post. Would it be easier to create my own pack items? I need 4 in total for now. These are the list of items I need to have a chance to open in the first pack. the amount of 1 for these is fine.

 

Pack 1: Random chance to get these items.

6861

6863

6853

6855

6857

6859

6865

6867

6869

6871

6873

6875

6877

6879

6881

6883

6885

6887

6889

6891

6893

6895

6897

6899

7580

6847

6849

6851

 

Pack 2 random chance to get these: Random amount 1-5

Sealed Tateossian Earring Part

Sealed Tateossian Ring Gem

Sealed Tateossian Necklace Chain

 

Sealed Imperial Crusader Breastplate Part

Sealed Imperial Crusader Gaiters Pattern

Sealed Imperial Crusader Gauntlets Design

Sealed Imperial Crusader Boots Design

Sealed Imperial Crusader Helmet Pattern

Sealed Imperial Crusader Shield Part

 

Sealed Draconic Leather Armor Part

Sealed Draconic Leather Gloves Fabric

Sealed Draconic Leather Boots Design

Sealed Draconic Leather Helmet Pattern

 

Sealed Major Arcana Robe Part

Sealed Major Arcana Gloves fabric

Sealed Major Arcana Boots Design

Sealed Major Arcana Circlet Pattern

 

Forgotten Blade Edge

Basalt Battlehammer Head

Imperial Staff Head

Angel Slayer Blade

Shining Bow Shaft

Dragon Hunter Axe Blade

Saint Spear Blade

Demon Splinter Blade

Heavens Divider Edge

Draconic Bow Shaft

Arcana Mace Head

 

Pack 3 random chance to get these items: Random amount 1-3

Arcsmith's Anvil

Warsmith's Mold

Leolin's Mold

Maestro Mold

Warsmith's Holder

 

Pack 4 random chance to get these items: Random amount 1-5

Compound Braid

Durable Metal Plate

Enria

Metallic Fiber

Varnish of Purity

Thons

Oriharukon

Coarse Bone Powder

Synthetic Cokes

Mithril Alloy

Asofe

 

I will be getting the item codes for those later but this is just to show you want I'm trying to do.

  • 0
Posted
package net.iplay.gameserver.handler.itemhandlers;

import net.iplay.gameserver.handler.IItemHandler;
import net.iplay.gameserver.model.actor.instance.L2ItemInstance;
import net.iplay.gameserver.model.actor.instance.L2PcInstance;
import net.iplay.gameserver.model.actor.instance.L2PlayableInstance;
import net.iplay.gameserver.network.SystemMessageId;
import net.iplay.gameserver.network.serverpackets.ItemList;
import net.iplay.gameserver.network.serverpackets.SystemMessage;
import net.iplay.util.Rnd;

public class YourCustomClass implements IItemHandler
{
private static final int[] ITEM_IDS =
{ 
	1,2 //packs ids
};

private int[] Pack1 = {6847,6849,6851,6853,6855,6857,6859,6861,6863,6865,6867,6869,6871,6873,6875,6877,6879,6881,6883,6885,6887,6889,6891,6893,6895,6897,6899,7580};
private int[] Pack2 = { /**anothers ids*/};

public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
	if (!(playable instanceof L2PcInstance))
		return;
	L2PcInstance activeChar = (L2PcInstance) playable;

	int itemId = item.getItemId();
	int itemToCreateId = 0;
	int amount = 0;

	switch(itemId)
	{
		case 1: //first pack id
		{
			if(getChance(30))
			{
				itemToCreateId = Pack1[Rnd.get(Pack1.length)];
				amount = 1;
			}
			break;
		}
		case 2: //second pack id
		{
			if(getChance(Rnd.get(30, 70))) // random chance
			{
				itemToCreateId = Pack2[Rnd.get(Pack2.length)];
				amount = Rnd.get(1, 5);
			}
			break;
		}
	}

	activeChar.getInventory().destroyItem("Extract", item, activeChar, null);
	activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);

	SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
	sm.addItemName(itemToCreateId);
	sm.addNumber(amount);
	activeChar.sendPacket(sm);

	ItemList playerUI = new ItemList(activeChar, false);
	activeChar.sendPacket(playerUI);
}

private boolean getChance(int i)
{
	return i > Rnd.get(100);
}

public int[] getItemIds()
{
	return ITEM_IDS;
}
}

  • 0
Posted

Maybe I did this wrong but I used 4 ids from the compressed soulshot pack, when I open them I still get soulshots.

package lt.equal.gameserver.handler.itemhandlers;

 

import lt.equal.gameserver.handler.IItemHandler;

import lt.equal.gameserver.model.L2ItemInstance;

import lt.equal.gameserver.model.actor.instance.L2PcInstance;

import lt.equal.gameserver.model.actor.instance.L2PlayableInstance;

import lt.equal.gameserver.network.SystemMessageId;

import lt.equal.gameserver.network.serverpackets.ItemList;

import lt.equal.gameserver.network.serverpackets.SystemMessage;

import lt.equal.util.Rnd;

 

public class CompShotPacks implements IItemHandler

{

private static final int[] ITEM_IDS =

{

5134, 5135, 5136, 5137 //packs ids

};

 

private int[] Pack1 = {6847,6849,6851,6853,6855,6857,6859,6861,6863,6865,6867,6869,6871,6873,6875,6877,6879,6881,6883,6885,6887,6889,6891,6893,6895,6897,6899,7580};

private int[] Pack2 = {1889,5550,4042,1895,1887,4044,1893,1881,1888,1890,4043};

private int[] Pack3 = {5553,5552,5551,4048,5554};

private int[] Pack4 = {6698,6699,6700,6701,6702,6703,6704,6706,6705,6707,6708,6709,6710,6711,6712,6713,6714,6688,6689,6690,6691,6692,6693,6694,6695,6696,7579,6697};

 

public void useItem(L2PlayableInstance playable, L2ItemInstance item)

{

if (!(playable instanceof L2PcInstance))

return;

L2PcInstance activeChar = (L2PcInstance) playable;

 

int itemId = item.getItemId();

int itemToCreateId = 0;

int amount = 0;

 

switch(itemId)

{

case 1: //first pack id

{

if(getChance(30))

{

itemToCreateId = Pack1[Rnd.get(Pack1.length)];

amount = 1;

}

break;

}

case 2: //second pack id

{

if(getChance(Rnd.get(30, 70))) // random chance

{

itemToCreateId = Pack2[Rnd.get(Pack2.length)];

amount = Rnd.get(1, 5);

}

break;

}

case 3: //third pack id

{

if(getChance(Rnd.get(30, 70))) // random chance

{

itemToCreateId = Pack3[Rnd.get(Pack3.length)];

amount = Rnd.get(1, 2);

}

break;

}

case 4: //fourth pack id

{

if(getChance(Rnd.get(30, 70))) // random chance

{

itemToCreateId = Pack4[Rnd.get(Pack4.length)];

amount = Rnd.get(1, 3);

}

break;

}

}

 

activeChar.getInventory().destroyItem("Extract", item, activeChar, null);

activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);

 

SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);

sm.addItemName(itemToCreateId);

sm.addNumber(amount);

activeChar.sendPacket(sm);

 

ItemList playerUI = new ItemList(activeChar, false);

activeChar.sendPacket(playerUI);

}

 

private boolean getChance(int i)

{

return i > Rnd.get(100);

}

 

public int[] getItemIds()

{

return ITEM_IDS;

}

}

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

    • L2jBayev Chronicle 3: Rise of Darkness – AiEngine Edition In short: this is a C3 build with a full-fledged AI engine, live mercenaries, a built-in quiz, a “personal account” in the Community Board, and server logic neatly distributed across thread pools. The project is about a living world without lags : bots farm, communicate, gather parties, teleport along routes, and the server remains cold and stable.   What's inside (the most delicious) 1) Full-fledged AI engine for characters Behavior types: farming ( FarmAI ), combat ( CombatAI ), party logic ( PartyAI ), trading/walking ( TraderAI / WalkerAI ), support roles (healer, etc.). Class profiles: for mages/archers/daggers, etc., “smart” skill rotations, distance control, sleep/save skills, healing, loot pickup, etc. are implemented (see examples of classes like SpellSingerAI , NecromancerAI , etc.). Self-healing and teleports: when dying, the bot goes through a sequence of steps without sleep()- via AITaskSequence + AITeleportToLocTask , searches for the nearest gatekeeper and teleports via TeleportationManager with routes depending on the level. Auto-support: auto-nipples, arrows/bones, smart auto-proceduring of buffs and auto-banks CP/HP/MP with thresholds - all sewn into the auxiliary EtcPlayersAi . Chat context: ChatManagerAi processes mentions, makes responses with delays (anti-flood), supports party chat and “human” reaction. Understanding: ChatManagerAi system  processes the dialogue, bots remember your aggression and insults, they start to respond less often to modern users, stop accepting or inviting to a group (party) and when it goes beyond the peak they will simply merge you, and every time they see you on the PC, there is an opportunity to measure more often, communicate respectfully and beautifully, in general, a “human” reaction. Why a player/admin needs this: bots actually “live”, farm and interact, and don’t just stand on macros. This is a great background for online and PvE action.   2) Mercenaries (Mercenary system) Full-fledged companion character : L2MercenaryInstance with its own MercenaryAI (movement, attack, support, consumables, shots). Behavior modes: DEFENDER / SUPPORT / PASSIVE - switchable to suit your playing style. Progress and trust: the mercenary's trust/exp/level grows , skills are learned according to the MercenarySkillTree (conditions are based on the trust or level of the owner). Templates and equipment: via MercenaryTemplateTable and spawner - model/weapon/type are selected. Social: MercenarySpeechManager - a set of speeches; the mercenary "comes to life" in the chat. Premium Link: Premium account owners give the mercenary additional trust (faster progress). Why: This is not a dummy pet, but a playful companion with modes, training and “character”.   3) Quiz (event viktorina ) Rounds according to schedule: pre-launch with announcements (minutes/seconds before start), registration .reg, auto-opening of the window. Multiple choice questions: question + set of answer buttons; fair processing, timings, question change. Tops and history: results table, statistics, neat UI via HTML assembly. Flexible control: you can start immediately or set a delayed start (notification package 5/2/1 min, etc.). Why: regular activity for players, “social entertainment” module right in the build.   4) Personal account in Community Board KB managers: buff cabinet, teleports, clans/forums/mail/friends, tops (PK/PvP/wealth/players), character repair, viewing skill trees , etc. Premium logic: some services/mail are limited by premium; premium also affects the visual (nickname color) and bonuses (see effect on mercenary). Single sign-on: all in one place, no team chaos. Why: conveniently manage your character and services without going into the console or installing third-party mods.   Why is the system technically valuable? Minimum load and stability Separated thread pools: AI logic, hunting, teleports, chat - on separate onesScheduledExecutorService ( AI_THREAD_POOL , MONSTER_HUNT_POOL , TELEPORT_POOL , CHAT_POOL ). No "freezing": task sequencers (teleport/recovery) work through the scheduler, not Thread.sleep(). Bot limitation: protection against overload via thresholds/counters - “extra” bots do not start. One bot - one sequence: AITaskManager ensures that the character does not have parallel conflicting tasks. Smoothing out peaks: starting tasks with offsets so that there are no simultaneous “ticks” of hundreds of bots. Monitoring/logs: own loggers (separate files for info/errors/processes/chats), CPU load monitoring. Bottom line: the build is designed for “thick online” and mass activities without TPS failures .   Additional Features Auto-alliances for farming: party logic invites suitable players (checking level/equipment/clan flags), there are “human” responses to requests. Sub/class management: out of the box helpers for changing class/subclass, auto-learning of necessary skills and selection of equipment by level. Security/protection: secondary PIN/picture password support (used in KB/voiced commands; optional). Premium accounts: privileges in KB/mail/visual and synergy with mercenary progress. Ready-made services: tops, auctions/mail, teleports from KB, buff rooms, repairs, viewing skill trees, etc.   Who is this build for? Freeshare/project admins who want a living world “from the pack”: bots and mercenaries provide a constant background of activity. Players who value convenience: personal account, premium services, events and a mercenary companion. Developers who want a clean, predictable backend with thread pools and a neat task model without “magic”.   How it differs from standard assemblies Not macros - AI profiles with “brains”: rotations, positioning, healing, decision making. Not a decoration pet - a mercenary with his own modes, progress, skill tree and lines. Not a faceless gamemod - an event quiz with UI, schedule, tops. No chaos in flows - strict pools, planning and task managers designed for online and growth. No separate scripts - a single personal account in KB for most activities.   TL;DR (one paragraph for the project card) AiEngine C3 is a build with live AI, smart bots, mercenaries (modes/progress/skills), built-in quiz, premium logic and a convenient personal account in KB. Under the hood are distributed thread pools and task managers without sleep(), so even with a dense online the server remains stable and responsive.   Additionally add - there is still a lot of interesting things command .assassin or shift+target (order murder), shift+target for admins on AI characters for control, admin panel is completely rewritten, many additional functions, mercenaries change their appearance depending on trust, deepseek and chatGPT system is connected for communication of characters like real players, GPT - for newer java, there is still a very large list of fixes after the last versions, a lot has been fixed, including height coordinates (Z) geo-Squares, pathfinding, visibility through obstacles, fix pet summons, trade packages, shop packages, many effects, quests (including the original ones like nipples, etc.), Ai behavior of NPC and RB monsters, absolutely all epics have been transferred to AiLoader no longer in python scripts. Attention! The server is suitable for both classic mode and PvP format, as well as with various mods. Absolutely everything is configured in the configurations to suit your taste and purposes of use. It is recommended to launch the server through L2ServerControl (simplifies management and control of processes). Download Servers: Chronicle 3 Server Chronicle 4 Test Upgraded Server Full Desc & screens: Post & Screens c3 Post & Desc c4    
    • 🎃 HALLOWEEN EVENT 🎃   ‼️ Information and details: https://forum.l2harbor.com/threads/halloween-event-fall-harvest-30-10-07-11.8265/post-168620
    • looking for good price adena or account or other things from lu4 black contact me telegram: hankowens or discord: brasca_17563
  • 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