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

    • We are looking for partners and account suppliers for cooperation We are open to partnerships with reliable account suppliers for the following dating services: ➡ Tinder ➡ Badoo ➡ Bumble ➡ Hinge ➡ Happn ➡ Meetic ➡ VK Dating We are considering long-term cooperation, stable volumes, and mutually beneficial terms. If you have any offers, we will be glad to discuss the details. Contact us using the details below. ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • We are looking for partners and account suppliers for cooperation We are open to partnerships with reliable account suppliers for the following dating services: ➡ Tinder ➡ Badoo ➡ Bumble ➡ Hinge ➡ Happn ➡ Meetic ➡ VK Dating We are considering long-term cooperation, stable volumes, and mutually beneficial terms. If you have any offers, we will be glad to discuss the details. Contact us using the details below. ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • We are looking for partners and account suppliers for cooperation We are open to partnerships with reliable account suppliers for the following dating services: ➡ Tinder ➡ Badoo ➡ Bumble ➡ Hinge ➡ Happn ➡ Meetic ➡ VK Dating We are considering long-term cooperation, stable volumes, and mutually beneficial terms. If you have any offers, we will be glad to discuss the details. Contact us using the details below. ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • 我们正在寻找合作伙伴和账号供应商进行合作 我们愿意与以下约会服务的可靠账号供应商建立合作关系: ➡ Tinder ➡ Badoo ➡ Bumble ➡ Hinge ➡ Happn ➡ Meetic ➡ VK Dating 我们考虑长期合作、稳定的供应量以及互利共赢的合作条件。 如果您有任何合作提议,我们很乐意讨论具体细节。 请通过以下联系方式与我们联系。 ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • We are looking for partners and account suppliers for cooperation We are open to partnerships with reliable account suppliers for the following dating services: ➡ Tinder ➡ Badoo ➡ Bumble ➡ Hinge ➡ Happn ➡ Meetic ➡ VK Dating We are considering long-term cooperation, stable volumes, and mutually beneficial terms. If you have any offers, we will be glad to discuss the details. Contact us using the details below. ➡ 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