Jump to content
  • 0

[Request] Rebirth System


Question

Posted

In frozen is rebirth system but you can't select skills

bypass -h custom_rebirth_requestrebirth

don't working. I need rebirth like in l2gold you can choose skills to rebirth.

I think you understand me, because my english is not very good, so please help me, THANKS!

4 answers to this question

Recommended Posts

  • 0
Posted

write down what U HAVE DONE ALREADY and in which part u have got a problem. Lines of code would be awesome

  • 0
Posted

/*
* This program 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.
* 
* This program 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.l2jfrozen.gameserver.model.entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.datatables.SkillTable;
import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
import com.l2jfrozen.gameserver.datatables.xml.ExperienceData;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;
import com.l2jfrozen.util.CloseUtil;
import com.l2jfrozen.util.database.L2DatabaseFactory;

/**
* <strong>This 'Custom Engine' was developed for L2J Forum Member 'sauron3256' on November 1st, 2008.</strong><br>
* <br>
* <strong>Quick Summary:</strong><br>
* This engine will grant the player special bonus skills at the cost of reseting him to level 1.<br>
* The -USER- can set up to X Rebirths, the skills received and their respective levels, and the item and price of each
* rebirth.<br>
* PLAYER's information is stored in an SQL Db under the table name: REBIRTH_MANAGER.<br>
* 
* @author <strong>Beetle and Shyla</strong>
*/
public class L2Rebirth
{

/** The current instance - static repeller. */
private static L2Rebirth _instance = null;

/** Basically, this will act as a cache so it doesnt have to read DB information on relog. */
private HashMap<Integer, Integer> _playersRebirthInfo = new HashMap<Integer, Integer>();

/**
 * Creates a new NON-STATIC instance.
 */
private L2Rebirth()
{
//Do Nothing ^_-
}

/**
 * Receives the non-static instance of the RebirthManager.
 *
 * @return single instance of L2Rebirth
 */
public static L2Rebirth getInstance()
{
	if(_instance == null)
	{
		_instance = new L2Rebirth();
	}
	return _instance;
}

/**
 * This is what it called from the Bypass Handler. (I think that's all thats needed here).
 *
 * @param player the player
 * @param command the command
 */
public void handleCommand(L2PcInstance player, String command)
{
	if(command.startsWith("custom_rebirth_requestrebirth"))
	{
		displayRebirthWindow(player);
	}
	else if(command.startsWith("custom_rebirth_confirmrequest"))
	{
		requestRebirth(player);
	}
}

/**
 * Display's an HTML window with the Rebirth Options.
 *
 * @param player the player
 */
public void displayRebirthWindow(L2PcInstance player)
{
	try
	{
		int currBirth = getRebirthLevel(player); //Returns the player's current birth level

		//Don't send html if player is already at max rebirth count.
		if(currBirth >= Config.REBIRTH_MAX)
		{
			player.sendMessage("You are currently at your maximum rebirth count!");
			return;
		}

		//Returns true if BASE CLASS is a mage.
		boolean isMage = player.getBaseTemplate().classId.isMage();
		//Returns the skill based on next Birth and if isMage.
		L2Skill skill = getRebirthSkill((currBirth + 1), isMage);

		String icon = "" + skill.getId();//Returns the skill's id.

		//Incase the skill is only 3 digits.
		if(icon.length() < 4)
		{
			icon = "0" + icon;
		}

		skill = null;
		icon = null;

	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}

/**
 * Checks to see if the player is eligible for a Rebirth, if so it grants it and stores information.
 *
 * @param player the player
 */
public void requestRebirth(L2PcInstance player)
{
	//Check the player's level.
	if(player.getLevel() < Config.REBIRTH_MIN_LEVEL)
	{
		player.sendMessage("You do not meet the level requirement for a Rebirth!");
		return;
	}

	else if(player.isSubClassActive())
	{
		player.sendMessage("Please switch to your Main Class before attempting a Rebirth.");
		return;
	}

	int currBirth = getRebirthLevel(player);
	int itemNeeded = 0;
	int itemAmount = 0;

	if(currBirth >= Config.REBIRTH_MAX)
	{
		player.sendMessage("You are currently at your maximum rebirth count!");
		return;
	}

	//Get the requirements
	int loopBirth = 0;
	for(String readItems : Config.REBIRTH_ITEM_PRICE) {
		String[] currItem = readItems.split(",");
		if (loopBirth == currBirth) {
			itemNeeded = Integer.parseInt(currItem[0]);
			itemAmount = Integer.parseInt(currItem[1]);
			break;
		}
		loopBirth++;
	}

	//Their is an item required
	if(itemNeeded != 0)
	{
		//Checks to see if player has required items, and takes them if so.
		if(!playerIsEligible(player, itemNeeded, itemAmount))
			return;
	}

	//Check and see if its the player's first Rebirth calling.
	boolean firstBirth = currBirth == 0;
	//Player meets requirements and starts Rebirth Process.
	grantRebirth(player, (currBirth + 1), firstBirth);
}

/**
 * Physically rewards player and resets status to nothing.
 *
 * @param player the player
 * @param newBirthCount the new birth count
 * @param firstBirth the first birth
 */
public void grantRebirth(L2PcInstance player, int newBirthCount, boolean firstBirth)
{
	try
	{
		double actual_hp = player.getCurrentHp();
		double actual_cp = player.getCurrentCp();

		int max_level = ExperienceData.getInstance().getMaxLevel();

		if(player.isSubClassActive())
		{
			max_level = Config.MAX_SUBCLASS_LEVEL;
		}

		//Protections
		Integer returnToLevel = Config.REBIRTH_RETURN_TO_LEVEL;
		if (returnToLevel < 1) 
			returnToLevel = 1; 
		if (returnToLevel > max_level) 
			returnToLevel = max_level;

		//Resets character to first class.
		player.setClassId(player.getBaseClass());

		player.broadcastUserInfo();

		final byte lvl = Byte.parseByte(returnToLevel+"");

		final long pXp = player.getStat().getExp();
		final long tXp = ExperienceData.getInstance().getExpForLevel(lvl);

		if(pXp > tXp)
		{
			player.getStat().removeExpAndSp(pXp - tXp, 0);
		}
		else if(pXp < tXp)
		{
			player.getStat().addExpAndSp(tXp - pXp, 0);
		}

		//Remove the player's current skills.
		for(L2Skill skill : player.getAllSkills())
		{
			player.removeSkill(skill);
		}
		//Give players their eligible skills.
		player.giveAvailableSkills();

		//restore Hp-Mp-Cp
		player.setCurrentCpDirect(actual_cp);
		player.setCurrentMpDirect(player.getMaxMp());
		player.setCurrentHpDirect(actual_hp);
		player.broadcastStatusUpdate();

		//Updates the player's information in the Character Database.
		player.store();

		if(firstBirth)
		{
			storePlayerBirth(player);
		}
		else
		{
			updatePlayerBirth(player, newBirthCount);
		}

		//Give the player his new Skills.
		grantRebirthSkills(player);


		//Displays a congratulation message to the player.
		displayCongrats(player);
		returnToLevel = null;
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}

/**
 * Special effects when the player levels.
 *
 * @param player the player
 */
public void displayCongrats(L2PcInstance player)
{
	//Victory Social Action.
	player.setTarget(player);
	player.broadcastPacket(new SocialAction(player.getObjectId(), 3));
	player.sendMessage("Congratulations " + player.getName() + ". You have been REBORN!");
	player.sendMessage("You got the passive skill!");
}

/**
 * Check and verify the player DOES have the item required for a request. Also, remove the item if he has.
 *
 * @param player the player
 * @param itemId the item id
 * @param itemAmount the item amount
 * @return true, if successful
 */
public boolean playerIsEligible(L2PcInstance player, int itemId, int itemAmount)
{
	String itemName = ItemTable.getInstance().getTemplate(itemId).getName();
	L2ItemInstance itemNeeded = player.getInventory().getItemByItemId(itemId);

	if(itemNeeded == null || itemNeeded.getCount() < itemAmount)
	{
		player.sendMessage("You need atleast " + itemAmount + "  [ " + itemName + " ] to request a Rebirth!");
		return false;
	}

	//Player has the required items, so we're going to take them!
	player.getInventory().destroyItemByItemId("Rebirth Engine", itemId, itemAmount, player, null);
	player.sendMessage("Removed " + itemAmount + " " + itemName + " from your inventory!");

	itemName = null;
	itemNeeded = null;

	return true;
}

/**
 * Gives the available Bonus Skills to the player.
 *
 * @param player the player
 */
public void grantRebirthSkills(L2PcInstance player)
{
	//returns the current Rebirth Level
	int rebirthLevel = getRebirthLevel(player);
	//Returns true if BASE CLASS is a mage.
	boolean isMage = player.getBaseTemplate().classId.isMage();

	//Simply return since no bonus skills are granted.
	if(rebirthLevel == 0)
		return;

	  //Load the bonus skills unto the player.
	  CreatureSay rebirthText = null;
	  for(int i = 0; i < rebirthLevel; i++)
	  {
	   L2Skill bonusSkill = getRebirthSkill((i + 1), isMage);
	   player.addSkill(bonusSkill, false);
	  }
}
/**
 * Return the player's current Rebirth Level.
 *
 * @param player the player
 * @return the rebirth level
 */
public int getRebirthLevel(L2PcInstance player)
{
	int playerId = player.getObjectId();

	if(_playersRebirthInfo.get(playerId) == null)
	{
		loadRebirthInfo(player);
	}

	return _playersRebirthInfo.get(playerId);
}

/**
 * Return the L2Skill the player is going to be rewarded.
 *
 * @param rebirthLevel the rebirth level
 * @param mage the mage
 * @return the rebirth skill
 */
public L2Skill getRebirthSkill(int rebirthLevel, boolean mage)
{
	L2Skill skill = null;

	//Player is a Mage.
	if(mage)
	{	
		int loopBirth = 0;
		for(String readSkill : Config.REBIRTH_MAGE_SKILL) {
			String[] currSkill = readSkill.split(",");
			if (loopBirth == (rebirthLevel-1)) {
				skill = SkillTable.getInstance().getInfo(Integer.parseInt(currSkill[0]), Integer.parseInt(currSkill[1]));
				break;
			}
			loopBirth++;
		}
	}
	//Player is a Fighter.
	else
	{
		int loopBirth = 0;
		for(String readSkill : Config.REBIRTH_FIGHTER_SKILL) {
			String[] currSkill = readSkill.split(",");
			if (loopBirth == (rebirthLevel-1)) {
				skill = SkillTable.getInstance().getInfo(Integer.parseInt(currSkill[0]), Integer.parseInt(currSkill[1]));
				break;
			}
			loopBirth++;
		}
	}
	return skill;
}

/**
 * Database caller to retrieve player's current Rebirth Level.
 *
 * @param player the player
 */
public void loadRebirthInfo(L2PcInstance player)
{
	int playerId = player.getObjectId();
	int rebirthCount = 0;

	Connection con = null;
	try
	{
		ResultSet rset;
		con = L2DatabaseFactory.getInstance().getConnection(false);
		PreparedStatement statement = con.prepareStatement("SELECT * FROM `rebirth_manager` WHERE playerId = ?");
		statement.setInt(1, playerId);
		rset = statement.executeQuery();

		while(rset.next())
		{
			rebirthCount = rset.getInt("rebirthCount");
		}

		rset.close();
		statement.close();
		statement = null;
		rset = null;

	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	finally
	{
		CloseUtil.close(con);
		con = null;
	}
	_playersRebirthInfo.put(playerId, rebirthCount);
}

/**
 * Stores the player's information in the DB.
 *
 * @param player the player
 */
public void storePlayerBirth(L2PcInstance player)
{
	Connection con = null;
	try
	{
		con = L2DatabaseFactory.getInstance().getConnection(false);
		PreparedStatement statement = con.prepareStatement("INSERT INTO `rebirth_manager` (playerId,rebirthCount) VALUES (?,1)");
		statement.setInt(1, player.getObjectId());
		statement.execute();
		statement = null;

		_playersRebirthInfo.put(player.getObjectId(), 1);

	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	finally
	{
		CloseUtil.close(con);
		con = null;
	}
}

/**
 * Updates the player's information in the DB.
 *
 * @param player the player
 * @param newRebirthCount the new rebirth count
 */
public void updatePlayerBirth(L2PcInstance player, int newRebirthCount)
{
	Connection con = null;
	try
	{
		int playerId = player.getObjectId();

		con = L2DatabaseFactory.getInstance().getConnection(false);
		PreparedStatement statement = con.prepareStatement("UPDATE `rebirth_manager` SET rebirthCount = ? WHERE playerId = ?");
		statement.setInt(1, newRebirthCount);
		statement.setInt(2, playerId);
		statement.execute();
		statement = null;

		_playersRebirthInfo.put(playerId, newRebirthCount);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	finally
	{
		CloseUtil.close(con);
		con = null;
	}
}
}

 

as i understand in npc need put this custom_rebirth_requestrebirth to popout window with skill choose, but this don't working, working only custom_rebirth_confirmrequest

Guest
This topic is now closed to further replies.


  • Posts

    • I connected everything without any problems. Does anyone know why I'm not getting experience for killing mobs? Has anyone encountered this? I'm setting the rates to x300, but it still doesn't give experience or level for killing mobs.
    • I'm using Myext64 HF and recently tried to replicate the "br_xmas09_event" Raising Rudolph Event. Detailed event information can be found at https://legacy-lineage2.com/news/_rudolf_the_red.html After configuring .eventdata.xml and starting the server, t  server log shows: 12/02/2025 15:39:01.809, [NO_ERROR] SpawnEx2 [br_xmas2009_invisible][schuttgart20_npc2213_xs03m1] [1][0][0][0][0][346796390] 12/02/2025 15:39:02.057, DummyPacket received from L2Server 12/02/2025 15:39:02.058, server socket close 312ac(f0820224) error(997) 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][0] Begin 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][2][1] void IOThread_common 1 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][4][3] void __cdecl CServerSocket::OnClose(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][5] End l2server log: 12/02/2025 15:39:02.112, npc server closed(127.0.0.1) error: 64 read buffer size: (server:0 npc:0) 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.131, dwTime[0] < 80 !!!!!!! 12/02/2025 15:39:02.131, [CallStack][tid:7][tick:1][0] Begin 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][2][1] void IOThread_common 1 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][4][3] void __cdecl NpcSocket::OnClose(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][5] End 12/02/2025 15:39:31.767, server closed(127.0.0.1) Error: 64 Read buffer size: (server:0 npc:0) 12/02/2025 15:39:31.768, [NO_ERROR] Logout All Characters : 1   The NPC server sent a packet to the L2 server while generating the br_xmas2009_invisible game NPC server, and the NPC server subsequently crashed.     After some digging, I found a clue in a very old MXC post, but the fix was for the GF version. The whole problem is in l2server side support for NPC function CreateOnePrivateNearUser. It sends CreatePacket but Koreans made some changes in it (added instance ID) so it got broken. As Santa event is the only AI that uses this function, they probably don't know about it    So is there a way to fix this problem, specifically for Myext64 HF? I'd be happy to buy him coffee. set_compiler_opt base_event_type(@NTYPE_NPC_EVENT) class ai_br_vital_manager : default_npc { parameter: int br_vitality2010_EVENT_ID = 20108888; handler: EventHandler CREATED() { } EventHandler TALKED(talker) { ShowPage(talker, "br_vi_stevu001.htm"); super; } EventHandler GIVE_EVENT_DATA(talker, i0, i1, i2, i3, i4) { i3 = i2 / 3600; i2 = i2 - i3 * 3600; i4 = i2 / 60; i2 = i2 - i4 * 60; if (i1 == 20108888) { if (i0 == 1) { CastBuffForQuestReward(talker, @s_br_vitality_day_1); CastBuffForQuestReward(talker, @s_br_vitality_day_2); ShowPage(talker, "br_vi_stevu002.htm"); } else { ShowPage(talker, "br_vi_stevu003.htm"); } } } EventHandler MENU_SELECTED(talker, ask, reply, c0) { if (ask == 50021) { select (reply) { case 1: CanGiveEventData(talker, 20108888); break; case 2: if (talker.level <= 75) { ShowPage(talker, "br_vi_stevu005.htm"); } else if (IsInCategory(@fighter_group, talker.occupation)) { CastBuffForQuestReward(talker, @s_wind_walk_for_newbie); CastBuffForQuestReward(talker, @s_shield_for_newbie); CastBuffForQuestReward(talker, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(talker, @s_bless_the_body_for_newbie); CastBuffForQuestReward(talker, @s_vampiric_rage_for_newbie); CastBuffForQuestReward(talker, @s_regeneration_for_newbie); CastBuffForQuestReward(talker, @s_haste_for_adventurer); ShowPage(talker, "br_vi_stevu006.htm"); } else if (IsInCategory(@mage_group, talker.occupation)) { CastBuffForQuestReward(talker, @s_wind_walk_for_newbie); CastBuffForQuestReward(talker, @s_shield_for_newbie); CastBuffForQuestReward(talker, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(talker, @s_bless_the_soul_for_newbie); CastBuffForQuestReward(talker, @s_acumen_for_newbie); CastBuffForQuestReward(talker, @s_concentration_for_newbie); CastBuffForQuestReward(talker, @s_empower_for_newbie); ShowPage(talker, "br_vi_stevu007.htm"); } break; case 3: c0 = GetSummon(talker); if (talker.level <= 75) { ShowPage(talker, "br_vi_stevu011.htm"); } else if (IsNullCreature(c0) == 0 && IsInCategory(@summon_npc_group, c0.class_id) && IsInCategory(@pet_group, c0.class_id) == 0) { CastBuffForQuestReward(c0, @s_wind_walk_for_newbie); CastBuffForQuestReward(c0, @s_shield_for_newbie); CastBuffForQuestReward(c0, @s_magic_barrier_for_adventurer); CastBuffForQuestReward(c0, @s_bless_the_body_for_newbie); CastBuffForQuestReward(c0, @s_vampiric_rage_for_newbie); CastBuffForQuestReward(c0, @s_regeneration_for_newbie); CastBuffForQuestReward(c0, @s_bless_the_soul_for_newbie); CastBuffForQuestReward(c0, @s_acumen_for_newbie); CastBuffForQuestReward(c0, @s_concentration_for_newbie); CastBuffForQuestReward(c0, @s_empower_for_newbie); CastBuffForQuestReward(c0, @s_haste_for_adventurer); ShowPage(talker, "br_vi_stevu009.htm"); } else { ShowPage(talker, "br_vi_stevu010.htm"); } break; } } } } Another one is about the " br_vitality2010_event event".   GIVE_EVENT_DATA is likely the only one in the activity AI script that uses this handle.      
    • Offtopic, personal attacks, probably too old to use that much memes and what's YOUR actual contribution to L2J, in order I laugh aswell ?   The main poster quotes my pack so I answer accordingly, while you advertise L2JFrozen in both of your posts - discontinued since 2014 (? 1132 rev), with none taking back the open source lead while anyone could.   If you're somewhat affiliated to hopzone, you probably packed way more money than me. Packs don't make any type of money (barely 100e/month) and if you would follow me, you would know there are ways to handle it or even getting paid.   Hope I was short enough, 🧂🤡.
    • Hi guys, this is a CMS im sharing for lineage 2 servers, im tired of the crap i see on new release servers. Dont let me start on the IA developed ones lmao.   📋 Description Free and open source template to create landing pages for Lineage 2 private servers. Designed with a dark fantasy theme and modern animations. ✨ Current Features This FREE version includes: Complete Landing Page - Professional design ready to use Multi-language Support - Spanish, English, Portuguese Dark Fantasy Theme - With animated UI elements Server Information - Rates, features, and rules Olympiad Ranking - Rankings display Download Section - For game client Skins and Animations Gallery Streaming Widget - Twitch/Kick integration Fully Customizable - Via configuration files ❌ Not Included in Free Version ❌ User Registration System ❌ Online Players Counter ❌ Donation Panel 💎 Premium Integrations IntegrationPrice Registration System $50 USD Online Players Counter $50 USD Donation Panel $50 USD   📧 Contact: https://gh0tstudio.com 🛠️ Tech Stack Technology    Version    Description React              19.2.0       UI Library TypeScript       5.8.2        Static typing Vite                 6.2.0         Build tool TailwindCSS   CDNCSS    Framework Lucide React   0.554.0         Icons i18next           23.16.0       Internationalization react-i18next   15.1.0        React bindings for i18n All documentation provided for AI AGENTS to make changes on the ui texts and so on. u can have a look on the cms fully working with donation panel, online count and register via: https://crmlineage2.vercel.app/ https://github.com/6h0T/CRM-LINEAGE2-FREE If u are in the lookings to develop a unique website for ur projects, u can dm me or contact me throw my socials on my profile. all code has encrypted references so any type of rebranding, copying or selling without authorization will result in take downs
  • 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