Jump to content
  • 0

Question about heroes


Question

10 answers to this question

Recommended Posts

  • 0
Posted

I didn't checked at all, but you surely need to recode some parts, because hero table is cleaned each time Olympiad occurs...

 

Baiscally, heroes are put heroes in EnterWorld, using database entries.

 

In the "hero clean section when olympiad occurs" you have to add a special symbol in an existing column "if column blabla == 999 don't delete the line", or to add a new column.

  • 0
Posted

should be

 

setHero(true)

 

example :

 

if (!isHero() && getLevel() == 80)

{

setHero(true);

rewardSkills();

}

 

just an example

 

 

sorry did misunderstood your question. try as matim said

  • 0
Posted

Or create your own "permanent heroes" table, with players with this stored there.

 

Or just as Tryskell said.

  • 0
Posted

the only "code" which exists for heroes into enterworld is this one

// Set Hero status if it applies

if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()))

activeChar.setHero(true);

 

setPledgeClass(activeChar);

 

so, what do you mean tryskell by adding a special symbol in an existing column? there isnt any column same as you told...

as for creating a new column, i didnt understand exactly what you mean matim...

  • 0
Posted

Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java	(revision 4492)
+++ java/com/l2jserver/gameserver/GameServer.java	(working copy)
@@ -41,6 +41,7 @@
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.datatables.CharTemplateTable;
import com.l2jserver.gameserver.datatables.ClanTable;
+import com.l2jserver.gameserver.datatables.CustomHeroTable;
import com.l2jserver.gameserver.datatables.DoorTable;
import com.l2jserver.gameserver.datatables.EnchantGroupsTable;
import com.l2jserver.gameserver.datatables.EnchantHPBonusData;
@@ -405,6 +406,7 @@

		TvTManager.getInstance();
		KnownListUpdateTaskManager.getInstance();
+		CustomHeroTable.getInstance();

		if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
			OfflineTradersTable.restoreOfflineTraders();
Index: java/com/l2jserver/gameserver/Shutdown.java
===================================================================
--- java/com/l2jserver/gameserver/Shutdown.java	(revision 4492)
+++ java/com/l2jserver/gameserver/Shutdown.java	(working copy)
@@ -21,6 +21,7 @@
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.datatables.ClanTable;
+import com.l2jserver.gameserver.datatables.CustomHeroTable;
import com.l2jserver.gameserver.datatables.OfflineTradersTable;
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
@@ -539,6 +540,8 @@
		ClanTable.getInstance().storeClanScore();
		_log.info("Clan System: Data saved!!");

+		CustomHeroTable.getInstance().saveHeros();
+		
		// Save Cursed Weapons data before closing.
		CursedWeaponsManager.getInstance().saveData();

Index: java/com/l2jserver/gameserver/datatables/CustomHeroTable.java
===================================================================
--- java/com/l2jserver/gameserver/datatables/CustomHeroTable.java	(revision 0)
+++ java/com/l2jserver/gameserver/datatables/CustomHeroTable.java	(revision 0)
@@ -0,0 +1,127 @@
+package com.l2jserver.gameserver.datatables;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+public class CustomHeroTable
+{
+	private static final class SingletonHolder
+	{
+		private static final CustomHeroTable INSTANCE = new CustomHeroTable();
+	}
+	
+	private static final Logger _log = Logger.getLogger(CustomHeroTable.class.getName());
+	
+	private static final String SQL_LOAD_HERO = "SELECT objecId FROM custom_hero";
+	private static final String SQL_DEL_HERO = "DELETE FROM custom_hero";
+	private static final String SQL_SAVE_HERO = "INSERT INTO custom_hero VALUES ( ? )";
+	
+	private Set<Integer> _heros;
+	
+	private CustomHeroTable()
+	{
+		_heros = new HashSet<Integer>();
+		loadHeros();
+	}
+	
+	private final void loadHeros()
+	{
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement st = con.prepareStatement(SQL_LOAD_HERO);
+			ResultSet rset = st.executeQuery();
+			while(rset.next())
+			{
+				final int objId = rset.getInt("objectId");
+				if(!addHero(objId))
+					_log.warning(">>> CustomHeroTable.loadHeros(): Duplicated object id in custom_hero table!");
+			}
+			_log.config("CustomHeroTable: Loaded "+_heros.size()+" custom Heroes!");
+		}
+		catch(SQLException e)
+		{
+			_log.log(Level.SEVERE, "CustomHeroTable.loadHeros()", e);
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+	}
+	
+	public final void saveHeros()
+	{
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			
+			PreparedStatement st = con.prepareStatement(SQL_DEL_HERO);
+			st.execute();
+			st.close();
+			
+			for(int hero : _heros)
+			{
+				PreparedStatement heroSt = con.prepareStatement(SQL_SAVE_HERO);
+				heroSt.setInt(1, hero);
+				heroSt.execute();
+				heroSt.close();
+			}
+			_log.config("CustomHeroTable: Suscessfully saved "+_heros.size()+" custom Heroes to database!");
+		}
+		catch(SQLException e)
+		{
+			_log.log(Level.SEVERE, "CustomHeroTable.saveHeros()", e);
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
+	}
+	
+	public void onEnter(L2PcInstance plr)
+	{
+		if(_heros.contains(plr.getObjectId()))
+			plr.setHero(true);
+	}
+	
+	/*
+	 * Following methods may be used for admin commands
+	 * or the way to become custom hero for example 
+	 */
+	
+	public boolean addHero(L2PcInstance plr)
+	{
+		return addHero(plr.getObjectId());
+	}
+	
+	public boolean addHero(int objectId)
+	{
+		return _heros.add(objectId);
+	}
+	
+	public boolean removeHero(L2PcInstance plr)
+	{
+		return removeHero(plr.getObjectId());
+	}
+	
+	public boolean removeHero(int objectId)
+	{
+		return _heros.remove(objectId);
+	}
+	
+	public static CustomHeroTable getInstance()
+	{
+		return SingletonHolder.INSTANCE;
+	}
+}
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(revision 4492)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -27,6 +27,7 @@
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
+import com.l2jserver.gameserver.datatables.CustomHeroTable;
import com.l2jserver.gameserver.datatables.GMSkillTable;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.datatables.SkillTable;
@@ -188,6 +189,8 @@
		if (activeChar.getCurrentHp() < 0.5)
			activeChar.setIsDead(true);

+		CustomHeroTable.getInstance().onEnter(activeChar);
+		
		boolean showClanNotice = false;

		// Clan related checks are here

l2jserver, freya last revision

  • 0
Posted

to apply and run this code you have to create a new table in database called custom_hero (with 1 column called objectId (INT, 10))

Those object ids from players who you add there will be permanent heros

Guest
This topic is now closed to further replies.


  • Posts

    • In case you can't find someone to exploit by paying him 10usd an hour and asking him to do thousands of dollars worth of work, please contact me.
    • 🎮 Stop staying offline — level up your Discord today!  🎁 Discord Nitro from just $2.9 — for yourself or as a gift!  🔑 Ready-to-use Discord accounts aged from 1 to 24 months starting at $0.44  💥 Everything you need to get started:  ✔️ Real Android devices, email + SMS verification (depends on the product)  ✔️ Nitro Classic & Full — 1 to 12 months (with or without account login)  ✔️ Unlimited accounts — perfect for bots, arbitrage, communities, marketing, and more   🚀 Promo code: DISCORD7 (7% discount)   Payment methods: bank cards · cryptocurrency · other popular options   How to buy:  ➡ Online Store: Click ✅  ➡ Telegram Bot: Click ✅   Other services:  ➡ SMM Panel: Click ✅   Assortment: 🤖 Discord accounts - mail:password:token with email included (email is working) Activated by SMS | ✨ 1 order = 3 accounts ✨ | Price from: $0.44  🤖 ⚡️DISCORD⚡️ Real Android devices ⚡️ Verified on RAMBLER.RU or FIRSTMAIL | Working email included | SMS (phone) verified ☑️ | Age from 3 months | Suitable for any purposes | Accounts without limitations or SMS | Price from: $0.5  🤖 ✨DISCORD✨ accounts | 1 order = 3 accounts | Verified email only (@rambler.ru / @firstmail), email included (working) | Gender: MIX | Price from: $0.5  🤖 ⚡️DISCORD⚡️ Real Android | ☑️ 1 order = 3 accounts | Verified via RAMBLER.RU or FIRSTMAIL | Working email included | SMS verified | Age from 1 month | Suitable for any purposes | Accounts without limitations or SMS | Price from: $0.75  🤖 ⚡️DISCORD⚡️ Real Android devices | Verified via RAMBLER.RU or FIRSTMAIL | Email included (may not work) | SMS verified | Age from 1 year | Suitable for any purposes | Accounts without limitations or SMS | Price from: $0.8  🤖 ⚡️DISCORD⚡️ Real Android devices | Verified via RAMBLER.RU or FIRSTMAIL | Email included (may not work) | SMS verified | Age from 2 years | Suitable for any purposes | Accounts without limitations or SMS | Price from: $1.5  🤖 ⚡️DISCORD⚡️ Real Android devices | Verified via RAMBLER.RU or FIRSTMAIL | Working email included | SMS verified | Age from 1 year | Suitable for any purposes | Accounts without limitations or SMS | Price from: $2  🤖 🎁 Discord Nitro Classic (Basic) | 1 MONTH | Requires login & password | Full subscription warranty | Price from: $2.9  🤖 🎁 Discord Nitro FULL | 1 MONTH | Requires login & password | Full subscription warranty | Price from: $4.9  🤖 🎁 Discord Nitro Classic (Basic) GIFT | 1 MONTH | No login required | Full subscription warranty | Price from: $3.5  🤖 🎁 Discord Nitro FULL | 12 MONTHS | Requires login & password | Full subscription warranty | Price from: $35  🤖 🎁 Discord Nitro Classic (Basic) GIFT | 12 MONTHS | No login required | Full subscription warranty | Price from: $17  🤖 🎁 Discord Nitro Classic (Basic) | 12 MONTHS | Requires login & password | Full subscription warranty | Price from: $15   Regular customers get extra discounts and promo codes!   Support:  ➡ Telegram: https://t.me/solomon_bog ✅  ➡ Discord: https://discord.gg/y9AStFFsrh ✅  ➡ WhatsApp: https://wa.me/79051904467 ✅  ➡ ✉ Email: solomonbog@socnet.store ✅   ➡ Telegram Channel: https://t.me/accsforyou_shop ✅   You can also use these contacts to:  — Discuss wholesale purchases  — Propose a partnership (current partners: https://socnet.bgng.io/partners )   — Become a supplier SocNet — Digital Goods & Premium Subscriptions Store ✅
    • maybe give some more info about your WTB topic like the language and what you want to develop, it doesnt have to be a full detail, it might help you thogh. about the topic author Joined: 07/14/2025
  • 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