l2jkain
Members-
Posts
207 -
Joined
-
Last visited
-
Feedback
0%
Content Type
Articles
Profiles
Forums
Store
Everything posted by l2jkain
-
Help TownManager aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
I created a check in ZoneManager for all town zones and it worked perfectly, this should work. ZoneManager.getInstance (). GetZoneById (i, TownZone.class) .setIsTWZone (true) I created this in ZoneManager public TownZone getTown (int townId) { for (TownZone temp: ZoneManager.getInstance (). getAllZones (TownZone.class)) { if (temp.getTownId () == townId) return temp; } return null; } -
Help TownManager aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
106 this TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true); for ZoneManager.getInstance().getZoneById(i, TownZone.class).setIsTWZone(true); -
Hi, I'm adapting the Town Manager event for aCis. When I change this TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true); for ZoneManager.getInstance().getZoneById(i, TownZone.class).setIsTWZone(true); generates the error what did I do wrong ? TownManager of jserver : public static final L2TownZone getTown(int townId) { for (L2TownZone temp : ZoneManager.getInstance().getAllZones(L2TownZone.class)) { if (temp.getTownId() == townId) { return temp; } } return null; } /** * Returns the town at that position (if any) * @param x * @param y * @param z * @return */ public static final L2TownZone getTown(int x, int y, int z) { for (L2ZoneType temp : ZoneManager.getInstance().getZones(x, y, z)) { if (temp instanceof L2TownZone) { return (L2TownZone) temp; } } return null; }
-
Help TeamVsTeam For aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
I'm doing my own engine sicronizei all the events I removed the methods of balancing of teams and I made the configs of all you left configs useful I made an afk system, all based on the system of the ATHENA engine. Yeah, it might suck to many for now. I will make a manage for all events soon -
Help TeamVsTeam For aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
I removed half of the code and created the cases in run () and it worked was improving the whole event removing the rubbish -
Hello I changed the INTERVAL event to String but it does not work, the event starts when the serve goes online. by : # Time Between TvT events (in minutes, 300 = 5 hours) TvTEventInterval = 1 for : # Times TvT will occur (24h format). # Example: 20:00,21,00,22:00 TvTEventInterval = 23:16 <---- Do not start at this time begins before code original : package net.sf.l2j.gameserver.model.entity; + +import net.sf.l2j.commons.concurrent.ThreadPool; + +import net.sf.l2j.Config; +import net.sf.l2j.gameserver.util.Broadcast; + +/** + * @author FBIagent + */ +public class TvTEventManager implements Runnable +{ + /** + * The one and only instance of this class<br> + */ + private static TvTEventManager _instance = null; + + /** + * New instance only by getInstance()<br> + */ + private TvTEventManager() + { + if (Config.TVT_EVENT_ENABLED) + { + ThreadPool.schedule(this, 0); + System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Started."); + } + else + System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Engine is disabled."); + } + + /** + * Initialize new/Returns the one and only instance<br> + * <br> + * @return TvTManager<br> + */ + public static TvTEventManager getInstance() + { + if (_instance == null) + _instance = new TvTEventManager(); + + return _instance; + } + + /** + * The task method to handle cycles of the event + * @see java.lang.Runnable#run() + */ + @Override + public void run() + { + TvTEvent.init(); + + for (;;) + { + waiter(Config.TVT_EVENT_INTERVAL * 60); // in config given as minutes + + if (!TvTEvent.startParticipation()) + { + Broadcast.announceToOnlinePlayers("TvT: Event was canceled.", true); + System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation."); + continue; + } + Broadcast.announceToOnlinePlayers("TvT: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s). Type .tvtjoin or .tvtleave", true); + + waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes + + if (!TvTEvent.startFight()) + { + Broadcast.announceToOnlinePlayers("TvT: Event canceled due to lack of Participation.", true); + System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event."); + continue; + } + Broadcast.announceToOnlinePlayers("TvT: Registration closed!", true); + TvTEvent.sysMsgToAllParticipants("TvT: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s)."); + + waiter(Config.TVT_EVENT_RUNNING_TIME * 60); // in config given as minutes + Broadcast.announceToOnlinePlayers(TvTEvent.calculateRewards(), true); + TvTEvent.sysMsgToAllParticipants("TvT: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s)."); + TvTEvent.stopFight(); + } + } + + /** + * This method waits for a period time delay + * @param seconds + */ + void waiter(int seconds) + { + while (seconds > 1) + { + seconds--; // here because we don't want to see two time announce at the same time + + if (TvTEvent.isParticipating() || TvTEvent.isStarted()) + { + switch (seconds) + { + case 3600: // 1 hour left + if (TvTEvent.isParticipating()) + Broadcast.announceToOnlinePlayers("TvT: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!", true); + else if (TvTEvent.isStarted()) + TvTEvent.sysMsgToAllParticipants("TvT: " + seconds / 60 / 60 + " hour(s) until event is finished!"); + + break; + case 1800: // 30 minutes left + case 900: // 15 minutes left + case 600: // 10 minutes left + case 300: // 5 minutes left + case 240: // 4 minutes left + case 180: // 3 minutes left + case 120: // 2 minutes left + case 60: // 1 minute left + if (TvTEvent.isParticipating()) + Broadcast.announceToOnlinePlayers("TvT: " + seconds / 60 + " minute(s) until registration is closed!", true); + else if (TvTEvent.isStarted()) + TvTEvent.sysMsgToAllParticipants("TvT: " + seconds / 60 + " minute(s) until the event is finished!"); + + break; + case 30: // 30 seconds left + /** + * case 15: // 15 seconds left case 10: // 10 seconds left + */ + case 5: // 5 seconds left + + /** + * case 4: // 4 seconds left case 3: // 3 seconds left case 2: // 2 seconds left case 1: // 1 seconds left + */ + if (TvTEvent.isParticipating()) + Broadcast.announceToOnlinePlayers("TvT: " + seconds + " second(s) until registration is closed!", true); + else if (TvTEvent.isStarted()) + TvTEvent.sysMsgToAllParticipants("TvT: " + seconds + " second(s) until the event is finished!"); + + break; + } + } + TvTEvent.waiter(1); + } + } +} code modified : package net.sf.l2j.gameserver.model.entity.jdev.engine.manager; import java.util.Calendar; import java.util.logging.Logger; import net.sf.l2j.commons.concurrent.ThreadPool; import net.sf.l2j.Config; import net.sf.l2j.gameserver.model.entity.jdev.engine.TeamVsTeam; import net.sf.l2j.gameserver.util.Broadcast; /** * @author FBIagent */ public class TvTManager implements Runnable { protected static final Logger _log = Logger.getLogger(TvTManager.class.getName()); public TvTManager() { if (Config.EVENTS_ENABLED) { ThreadPool.schedule(this, 0); _log.info("TeamVsTeam: Started."); } else _log.info("TeamVsTeam: Disabled."); } public static TvTManager getInstance() { return SingletonHolder._instance; } @Override public void run() { TeamVsTeam.init(); try { Calendar currentTime = Calendar.getInstance(); Calendar nextStartTime = null; Calendar testStartTime = null; for (String timeOfDay : Config.TVT_EVENT_INTERVAL) { testStartTime = Calendar.getInstance(); testStartTime.setLenient(true); String[] splitTimeOfDay = timeOfDay.split(":"); testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0])); testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1])); if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis()) testStartTime.add(Calendar.DAY_OF_MONTH, 1); if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()) nextStartTime = testStartTime; if (!TeamVsTeam.startParticipation()) { Broadcast.announceToOnlinePlayers("TeamVsTeam: Event was cancelled.", true); System.out.println("TeamVsTeam: Error spawning event npc for participation."); continue; } Broadcast.announceToOnlinePlayers("TeamVsTeam: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).", true); Broadcast.announceToOnlinePlayers("TeamVsTeam: Joinable in " + Config.EVENTS_JOIN_LOCATION + ".", true); Broadcast.announceToOnlinePlayers("TeamVsTeam:"+" Recruiting levels: " + Config.EVENTS_MIN_LVL + " to " + Config.EVENTS_MAX_LVL + ".", true); if (Config.TVT_VOICED_COMMAND) Broadcast.announceToOnlinePlayers("TeamVsTeam: Commands .TVTon .TVToff .TVTinfo.",true); waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes if (!TeamVsTeam.startFight()) { Broadcast.announceToOnlinePlayers("TeamVsTeam: Event cancelled due to lack of Participation.", true); System.out.println("TeamVsTeam: Lack of registration, abort event."); continue; } TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: Teleporting participants to an arena in " + Config.EVENTS_START_LEAVE_TELEPORT_DELAY + " second(s)."); waiter(Config.TVT_EVENT_RUNNING_TIME * 60); // in config given as minutes Broadcast.announceToOnlinePlayers(TeamVsTeam.calculateRewards(), true); TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: Teleporting back to the registration npc in " + Config.EVENTS_START_LEAVE_TELEPORT_DELAY + " second(s)."); TeamVsTeam.stopFight(); } } catch (Exception e) { _log.warning("TeamVsTeam: Error figuring out a start time. Check TVTEventInterval in config file."); } } void waiter(int seconds) { while (seconds > 1) { seconds--; // Here because we don't want to see two time announce at the same time if (TeamVsTeam.isParticipating() || TeamVsTeam.isStarted()) { switch (seconds) { case 3600: // 1 hour left if (TeamVsTeam.isParticipating()) Broadcast.announceToOnlinePlayers("TeamVsTeam: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!", true); else if (TeamVsTeam.isStarted()) TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + seconds / 60 / 60 + " hour(s) until event is finished!"); break; case 1800: // 30 minutes left case 900: // 15 minutes left case 600: // 10 minutes left case 300: // 5 minutes left case 240: // 4 minutes left case 180: // 3 minutes left case 120: // 2 minutes left case 60: // 1 minute left if (TeamVsTeam.isParticipating()) Broadcast.announceToOnlinePlayers("TeamVsTeam: " + seconds / 60 + " minute(s) until registration is closed!", true); else if (TeamVsTeam.isStarted()) TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + seconds / 60 + " minute(s) until the event is finished!"); break; case 30: // 30 seconds left case 15: // 15 seconds left case 10: // 10 seconds left case 3: // 3 seconds left case 2: // 2 seconds left case 1: // 1 seconds left if (TeamVsTeam.isParticipating()) Broadcast.announceToOnlinePlayers("TeamVsTeam: " + seconds + " second(s) until registration is closed!", true); else if (TeamVsTeam.isStarted()) TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + seconds + " second(s) until the event is finished!"); break; } } long startOneSecondWaiterStartTime = System.currentTimeMillis(); while (startOneSecondWaiterStartTime + 1000L > System.currentTimeMillis()) { try { Thread.sleep(1); } catch (final InterruptedException ie) { ie.printStackTrace(); } } } } private static class SingletonHolder { protected static final TvTManager _instance = new TvTManager(); } }
-
Topic resolved. get solved
-
Hello I'm improving this part more always of this error !! modified code try { NpcTemplate template = NpcData.getInstance().getTemplate(Config.CTF_EVENT_TEAM_1_HEADQUARTERS); L2Spawn spawn = new L2Spawn(template); spawn.setLoc(Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[2], 0); SpawnTable.getInstance().addNewSpawn(spawn, false); Npc npc = spawn.doSpawn(true); npc.scheduleDespawn(Config.CTF_EVENT_RUNNING_TIME * 1000 * 60); npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1)); template = NpcData.getInstance().getTemplate(Config.CTF_EVENT_TEAM_2_HEADQUARTERS); spawn = new L2Spawn(template); spawn.setLoc(Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[2], 0); SpawnTable.getInstance().addNewSpawn(spawn, false); npc = spawn.doSpawn(true); npc.scheduleDespawn(Config.CTF_EVENT_RUNNING_TIME * 1000 * 60); npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1)); } catch (Exception e) { _log.log(Level.WARNING, "CaptureTheFlag > spanwnFlags: " + e.getMessage(), e); } Code original try { NpcTemplate tmpl = NpcData.getInstance().getTemplate(Config.CTF_EVENT_TEAM_1_HEADQUARTERS); _flag1Spawn = new L2Spawn(tmpl); _flag1Spawn.setLoc(Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[2], MathUtil.calculateHeadingFrom(new Location(Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[2]), new Location(Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[2]))); _flag1Spawn.setRespawnDelay(1); SpawnTable.getInstance().addNewSpawn(_flag1Spawn, false); _flag1Spawn.setRespawnState(true); _flag1Spawn.doSpawn(false); _lastFlag1Spawn = _flag1Spawn.getNpc(); _lastFlag1Spawn.setCurrentHp(_lastFlag1Spawn.getMaxHp()); _lastFlag1Spawn.setTitle(Config.CTF_EVENT_TEAM_1_NAME); _lastFlag1Spawn.isAggressive(); _lastFlag1Spawn.decayMe(); _lastFlag1Spawn.spawnMe(_flag1Spawn.getNpc().getX(), _flag1Spawn.getNpc().getY(), _flag1Spawn.getNpc().getZ()); _lastFlag1Spawn.setIsInvul(true); NpcTemplate tmpl2 = NpcData.getInstance().getTemplate(Config.CTF_EVENT_TEAM_2_HEADQUARTERS); _flag2Spawn = new L2Spawn(tmpl2); _flag2Spawn.setLoc(Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[2], MathUtil.calculateHeadingFrom(new Location(Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_2_FLAG_COORDINATES[2]), new Location(Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[0], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[1], Config.CTF_EVENT_TEAM_1_FLAG_COORDINATES[2]))); _flag2Spawn.setRespawnDelay(1); SpawnTable.getInstance().addNewSpawn(_flag2Spawn, false); _flag2Spawn.setRespawnState(true); _flag2Spawn.doSpawn(false); _lastFlag2Spawn = _flag2Spawn.getNpc(); _lastFlag2Spawn.setCurrentHp(_lastFlag2Spawn.getMaxHp()); _lastFlag2Spawn.setTitle(Config.CTF_EVENT_TEAM_2_NAME); _lastFlag2Spawn.isAggressive(); _lastFlag2Spawn.decayMe(); _lastFlag2Spawn.spawnMe(_flag2Spawn.getNpc().getX(), _flag2Spawn.getNpc().getY(), _flag2Spawn.getNpc().getZ()); _lastFlag2Spawn.setIsInvul(true); _lastFlag2Spawn.setTarget(_lastFlag2Spawn); } catch (Exception e) { _log.log(Level.WARNING, "CTFEventEngine[CTFEvent.spanwnFlags]: exception: " + e.getMessage(), e); }
-
Hello would like help to leave the registration time every minute. package net.sf.l2j.gameserver.model.entity.capturetheflag; import java.util.Calendar; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import net.sf.l2j.Config; import net.sf.l2j.commons.concurrent.ThreadPool; import net.sf.l2j.gameserver.util.Broadcast; /** * @author FBIagent */ public class CTFManager { protected static final Logger _log = Logger.getLogger(CTFManager.class.getName()); /** Task for event cycles<br> */ private CTFStartTask _task; /** * New instance only by getInstance()<br> */ public CTFManager() { if (Config.CTF_EVENT_ENABLED) { CTFEvent.init(); this.scheduleEventStart(); _log.info("CTFEventEngine: Started."); } else { _log.info("CTFEventEngine: Disabled."); } } /** * Initialize new/Returns the one and only instance<br><br> * * @return CTFManager<br> */ public static CTFManager getInstance() { return SingletonHolder._instance; } /** * Starts CTFStartTask */ public void scheduleEventStart() { try { Calendar currentTime = Calendar.getInstance(); Calendar nextStartTime = null; Calendar testStartTime = null; for (String timeOfDay : Config.CTF_EVENT_INTERVAL) { // Creating a Calendar object from the specified interval value testStartTime = Calendar.getInstance(); testStartTime.setLenient(true); String[] splitTimeOfDay = timeOfDay.split(":"); testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0])); testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1])); // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.) if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis()) { testStartTime.add(Calendar.DAY_OF_MONTH, 1); } // Check for the test date to be the minimum (smallest in the specified list) if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()) { nextStartTime = testStartTime; } } if (nextStartTime != null) { _task = new CTFStartTask(nextStartTime.getTimeInMillis()); ThreadPool.execute(_task); } } catch (Exception e) { _log.warning("CTFEventEngine[CTFManager.scheduleEventStart()]: Error figuring out a start time. Check CTFEventInterval in config file."); } } /** * Method to start participation */ public void startReg() { if (!CTFEvent.startParticipation()) { Broadcast.announceToOnlinePlayers("CTF Event: Event was cancelled."); _log.warning("CTFEventEngine[CTFManager.run()]: Error spawning event npc for participation."); this.scheduleEventStart(); } else { Broadcast.announceToOnlinePlayers("CTF Event: Registration opened for " + Config.CTF_EVENT_PARTICIPATION_TIME + " minute(s).", true); Broadcast.announceToOnlinePlayers("CTF Event: Joinable in " + Config.CTF_JOIN_LOCATION + "."); if (Config.CTF_VOICED_COMMAND) Broadcast.announceToOnlinePlayers("CTF Event : Commands .ctfjoin .ctfleave .ctfinfo!"); // schedule registration end _task.setStartTime(System.currentTimeMillis() + 60000L * Config.CTF_EVENT_PARTICIPATION_TIME); ThreadPool.execute(_task); } } /** * Method to start the fight */ public void startEvent() { if (!CTFEvent.startFight()) { Broadcast.announceToOnlinePlayers("CTF Event: Event cancelled due to lack of Participation."); _log.info("CTFEventEngine[CTFManager.run()]: Lack of registration, abort event."); this.scheduleEventStart(); } else { CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting participants to an arena in " + Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s)."); _task.setStartTime(System.currentTimeMillis() + 60000L * Config.CTF_EVENT_RUNNING_TIME); ThreadPool.execute(_task); } } /** * Method to end the event and reward */ public void endEvent() { Broadcast.announceToOnlinePlayers(CTFEvent.calculateRewards()); CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting back to the registration npc in " + Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s)."); CTFEvent.stopFight(); this.scheduleEventStart(); } public void skipDelay() { if (_task.nextRun.cancel(false)) { _task.setStartTime(System.currentTimeMillis()); ThreadPool.execute(_task); } } /** * Class for CTF cycles */ class CTFStartTask implements Runnable { private long _startTime; public ScheduledFuture<?> nextRun; public CTFStartTask(long startTime) { _startTime = startTime; } public void setStartTime(long startTime) { _startTime = startTime; } /** * @see java.lang.Runnable#run() */ @Override public void run() { int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0); if (delay > 0) { this.announce(delay); } int nextMsg = 0; if (delay > 3600) { nextMsg = delay - 3600; } else if (delay > 1800) { nextMsg = delay - 1800; } else if (delay > 900) { nextMsg = delay - 900; } else if (delay > 600) { nextMsg = delay - 600; } else if (delay > 300) { nextMsg = delay - 300; } else if (delay > 60) { nextMsg = delay - 60; } else if (delay > 5) { nextMsg = delay - 5; } else if (delay > 0) { nextMsg = delay; } else { // start if (CTFEvent.isInactive()) { CTFManager.this.startReg(); } else if (CTFEvent.isParticipating()) { CTFManager.this.startEvent(); } else { CTFManager.this.endEvent(); } } if (delay > 0) { nextRun = ThreadPool.schedule(this, nextMsg * 1000); } } private void announce(long time) { if (time >= 3600 && time % 3600 == 0) { if (CTFEvent.isParticipating()) { Broadcast.announceToOnlinePlayers("CTF Event: " + (time / 60 / 60) + " hour(s) until registration is closed!"); } else if (CTFEvent.isStarted()) { CTFEvent.sysMsgToAllParticipants("CTF Event: " + (time / 60 / 60) + " hour(s) until event is finished!"); } } else if (time >= 60) { if (CTFEvent.isParticipating()) { Broadcast.announceToOnlinePlayers("CTF Event: " + (time / 60) + " minute(s) until registration is closed!"); } else if (CTFEvent.isStarted()) { CTFEvent.sysMsgToAllParticipants("CTF Event: " + (time / 60) + " minute(s) until the event is finished!"); } } else { if (CTFEvent.isParticipating()) { Broadcast.announceToOnlinePlayers("CTF Event: " + time + " second(s) until registration is closed!"); } else if (CTFEvent.isStarted()) { CTFEvent.sysMsgToAllParticipants("CTF Event: " + time + " second(s) until the event is finished!"); } } } } private static class SingletonHolder { protected static final CTFManager _instance = new CTFManager(); } }
-
Help TIntObjectHashMap aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
perfect , you can close the topic. -
how do I replace this class? Do not have the Trovan library at ACIS. private final TIntObjectHashMap SKILLS_HP = new TIntObjectHashMap<int[]>();
-
Code 1000pvps from item l2jacis
l2jkain replied to ThelwHelpRePaidia's topic in Server Shares & Files [L2J]
great content plus these restrictions do not need as it rewards players when they have 1000 pvp, they will not win the item with these restrictions, dead, combat, CursedWeaponEquipped, Karma. This restriction has some sense "Olympiad Mode". that is enough. package net.sf.l2j.gameserver.handler.itemhandlers; import net.sf.l2j.gameserver.handler.IItemHandler; import net.sf.l2j.gameserver.model.actor.Playable; import net.sf.l2j.gameserver.model.actor.instance.Player; import net.sf.l2j.gameserver.model.item.instance.ItemInstance; public class Pvpitem implements IItemHandler { @Override public void useItem(Playable playable, ItemInstance item, boolean forceUse) { if (!(playable instanceof Player)) return; Player player = (Player) playable; if (player.getActiveTradeList() != null || player.getActiveEnchantItem() != null) { player.sendMessage("Cannot use while trading/enchanting"); return; } final int pvps = player.getPvpKills() + 1000; player.setPvpKills(pvps); player.broadcastUserInfo(); player.sendMessage("Your PVP count is now " + pvps); playable.destroyItem("Consume", item.getObjectId(), 1, null, false); } } -
Help acis Weapons drop enchanted
l2jkain replied to ThelwHelpRePaidia's question in Request Server Development Help [L2J]
either of that model? -
Help Add item player Offline aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
thank you very much, I can do it Close the topic. -
Help Add item player Offline aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
I have refacted the code but it does not add anything in the player's bag offilne private static void addOfflineItem(int owner_id, int item_id, int count) { ItemInstance item = new ItemInstance(IdFactory.getInstance().getNextId(), count); try(Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement stm_items = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); stm_items.setInt(1, owner_id); stm_items.setInt(2, item.getItemId()); stm_items.setInt(3, count); item.setLocation(ItemLocation.WAREHOUSE); stm_items.setInt(5, 0); stm_items.setInt(6, item.getEnchantLevel()); stm_items.setInt(7, item.getObjectId()); stm_items.setInt(8, 0); stm_items.setInt(9, 0); stm_items.setInt(10, -1); stm_items.setLong(11, System.currentTimeMillis()); stm_items.executeUpdate(); stm_items.close(); } catch (SQLException e) { _log.severe("Could not update item char: " + e); } } -
Help Restriction of names aCis
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
get close the topic -
Hi, I'm trying to restrict certain names. It says that the name is incorrect plus it creates the character. Part : CharacterCreate.java if (Config.LIST_FORBIDDEN_NAMES.contains(_name.toLowerCase())) { sendPacket(CharCreateFail.REASON_INCORRECT_NAME); return; } Part Config.java public static List<String> LIST_FORBIDDEN_NAMES = new ArrayList<>(); LIST_FORBIDDEN_NAMES = new ArrayList<>(); for (String listid : server.getProperty("RestrictedNames", "fuck,dildo,admin").split(",")) { LIST_FORBIDDEN_NAMES.add(String.valueOf(listid)); } error
-
Sorry, I fixed it already.
-
https://pastebin.com/epSa6FQw credits : Williams
-
Help Enchant All Grades for aCis system Hasha Enchant
l2jkain replied to l2jkain's question in Request Server Development Help [L2J]
Example <enchant id="9999" grade="ALL" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- All grade - Donate Scrolls: Enchant Weapon --> -
Help Enchant All Grades for aCis system Hasha Enchant
l2jkain posted a question in Request Server Development Help [L2J]
Olá, como você colocaria um pergaminho em todas as redes? Não consigo configurar a grade de rolagem para todos. ### Eclipse Workspace Patch 1.0 #P aCis_datapack Index: data/xml/enchants.xml =================================================================== --- data/xml/enchants.xml (revision 0) +++ data/xml/enchants.xml (revision 0) @@ -0,0 +1,44 @@ +<?xml version='1.0' encoding='utf-8'?> +<list> + <!-- Scrolls: Enchant Weapon --> + <enchant id="959" grade="5" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Scrolls: Enchant Weapon --> + <enchant id="729" grade="4" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Scrolls: Enchant Weapon --> + <enchant id="947" grade="3" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Scrolls: Enchant Weapon --> + <enchant id="951" grade="2" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Scrolls: Enchant Weapon --> + <enchant id="955" grade="1" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Scrolls: Enchant Weapon --> + + <!-- Scrolls: Enchant Armor --> + <enchant id="960" grade="5" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Scrolls: Enchant Armor --> + <enchant id="730" grade="4" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Scrolls: Enchant Armor --> + <enchant id="948" grade="3" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Scrolls: Enchant Armor --> + <enchant id="952" grade="2" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Scrolls: Enchant Armor --> + <enchant id="956" grade="1" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Scrolls: Enchant Armor --> + + <!-- Blessed Scrolls: Enchant Weapon --> + <enchant id="6577" grade="5" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6569" grade="4" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6571" grade="3" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6573" grade="2" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6575" grade="1" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Blessed Scrolls: Enchant Weapon --> + + <!-- Blessed Scrolls: Armor Weapon --> + <enchant id="6578" grade="5" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6570" grade="4" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6572" grade="3" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6574" grade="2" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6576" grade="1" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Blessed Scrolls: Enchant Armor --> + + <!-- Crystal Scrolls: Enchant Weapon --> + <enchant id="961" grade="5" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="731" grade="4" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="949" grade="3" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="953" grade="2" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="957" grade="1" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Crystal Scrolls: Enchant Weapon --> + + <!-- Crystal Scrolls: Enchant Armor --> + <enchant id="962" grade="5" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="732" grade="4" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="950" grade="3" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="954" grade="2" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="958" grade="1" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Crystal Scrolls: Enchant Weapon --> +</list> \ No newline at end of file #P aCis_gameserver Index: java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java =================================================================== --- java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java (revision 5) +++ java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java (working copy) @@ -1,212 +0,0 @@ -/* - * 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 net.sf.l2j.gameserver.network.clientpackets; - -import java.util.HashMap; -import java.util.Map; - -import net.sf.l2j.Config; -import net.sf.l2j.gameserver.model.item.instance.ItemInstance; -import net.sf.l2j.gameserver.model.item.kind.Item; -import net.sf.l2j.gameserver.model.item.kind.Weapon; -import net.sf.l2j.gameserver.model.item.type.CrystalType; -import net.sf.l2j.gameserver.model.item.type.WeaponType; - -public abstract class AbstractEnchantPacket extends L2GameClientPacket -{ - public static final Map<Integer, EnchantScroll> _scrolls = new HashMap<>(); - - public static final class EnchantScroll - { - protected final boolean _isWeapon; - protected final CrystalType _grade; - private final boolean _isBlessed; - private final boolean _isCrystal; - - public EnchantScroll(boolean wep, boolean bless, boolean crystal, CrystalType type) - { - _isWeapon = wep; - _grade = type; - _isBlessed = bless; - _isCrystal = crystal; - } - - /** - * @param enchantItem : The item to enchant. - * @return true if support item can be used for this item - */ - public final boolean isValid(ItemInstance enchantItem) - { - if (enchantItem == null) - return false; - - // checking scroll type and configured maximum enchant level - switch (enchantItem.getItem().getType2()) - { - case Item.TYPE2_WEAPON: - if (!_isWeapon || (Config.ENCHANT_MAX_WEAPON > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON)) - return false; - break; - - case Item.TYPE2_SHIELD_ARMOR: - case Item.TYPE2_ACCESSORY: - if (_isWeapon || (Config.ENCHANT_MAX_ARMOR > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR)) - return false; - break; - - default: - return false; - } - - // check for crystal type - if (_grade != enchantItem.getItem().getCrystalType()) - return false; - - return true; - } - - /** - * @return true if item is a blessed scroll. - */ - public final boolean isBlessed() - { - return _isBlessed; - } - - /** - * @return true if item is a crystal scroll. - */ - public final boolean isCrystal() - { - return _isCrystal; - } - - /** - * Regarding enchant system :<br> - * <br> - * <u>Weapons</u> - * <ul> - * <li>magic weapons has chance of 40% until +15 and 20% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li> - * <li>non magic weapons has chance of 70% until +15 and 35% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li> - * </ul> - * <u>Armors</u> - * <ul> - * <li>non fullbody armors (jewelry, upper armor, lower armor, boots, gloves, helmets and shirts) has chance of 2/3 for +4, 1/3 for +5, 1/4 for +6, ...., 1/18 +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li> - * <li>full body armors has a chance of 1/1 for +4, 2/3 for +5, 1/3 for +6, ..., 1/17 for +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li> - * </ul> - * @param enchantItem : The item to enchant. - * @return the enchant chance under double format (0.7 / 0.35 / 0.44324...). - */ - public final double getChance(ItemInstance enchantItem) - { - if (!isValid(enchantItem)) - return -1; - - boolean fullBody = enchantItem.getItem().getBodyPart() == Item.SLOT_FULL_ARMOR; - if (enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX || (fullBody && enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX_FULL)) - return 1; - - double chance = 0; - - // Armor formula : 0.66^(current-2), chance is lower and lower for each enchant. - if (enchantItem.isArmor()) - chance = Math.pow(Config.ENCHANT_CHANCE_ARMOR, (enchantItem.getEnchantLevel() - 2)); - // Weapon formula is 70% for fighter weapon, 40% for mage weapon. Special rates after +14. - else if (enchantItem.isWeapon()) - { - if (((Weapon) enchantItem.getItem()).isMagical()) - chance = (enchantItem.getEnchantLevel() > 14) ? Config.ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS : Config.ENCHANT_CHANCE_WEAPON_MAGIC; - else - chance = (enchantItem.getEnchantLevel() > 14) ? Config.ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS : Config.ENCHANT_CHANCE_WEAPON_NONMAGIC; - } - - return chance; - } - } - - /** - * Format : itemId, (isWeapon, isBlessed, isCrystal, grade)<br> - * Allowed items IDs must be sorted by ascending order. - */ - static - { - // Scrolls: Enchant Weapon - _scrolls.put(729, new EnchantScroll(true, false, false, CrystalType.A)); - _scrolls.put(947, new EnchantScroll(true, false, false, CrystalType.B)); - _scrolls.put(951, new EnchantScroll(true, false, false, CrystalType.C)); - _scrolls.put(955, new EnchantScroll(true, false, false, CrystalType.D)); - _scrolls.put(959, new EnchantScroll(true, false, false, CrystalType.S)); - - // Scrolls: Enchant Armor - _scrolls.put(730, new EnchantScroll(false, false, false, CrystalType.A)); - _scrolls.put(948, new EnchantScroll(false, false, false, CrystalType.B)); - _scrolls.put(952, new EnchantScroll(false, false, false, CrystalType.C)); - _scrolls.put(956, new EnchantScroll(false, false, false, CrystalType.D)); - _scrolls.put(960, new EnchantScroll(false, false, false, CrystalType.S)); - - // Blessed Scrolls: Enchant Weapon - _scrolls.put(6569, new EnchantScroll(true, true, false, CrystalType.A)); - _scrolls.put(6571, new EnchantScroll(true, true, false, CrystalType.B)); - _scrolls.put(6573, new EnchantScroll(true, true, false, CrystalType.C)); - _scrolls.put(6575, new EnchantScroll(true, true, false, CrystalType.D)); - _scrolls.put(6577, new EnchantScroll(true, true, false, CrystalType.S)); - - // Blessed Scrolls: Enchant Armor - _scrolls.put(6570, new EnchantScroll(false, true, false, CrystalType.A)); - _scrolls.put(6572, new EnchantScroll(false, true, false, CrystalType.B)); - _scrolls.put(6574, new EnchantScroll(false, true, false, CrystalType.C)); - _scrolls.put(6576, new EnchantScroll(false, true, false, CrystalType.D)); - _scrolls.put(6578, new EnchantScroll(false, true, false, CrystalType.S)); - - // Crystal Scrolls: Enchant Weapon - _scrolls.put(731, new EnchantScroll(true, false, true, CrystalType.A)); - _scrolls.put(949, new EnchantScroll(true, false, true, CrystalType.B)); - _scrolls.put(953, new EnchantScroll(true, false, true, CrystalType.C)); - _scrolls.put(957, new EnchantScroll(true, false, true, CrystalType.D)); - _scrolls.put(961, new EnchantScroll(true, false, true, CrystalType.S)); - - // Crystal Scrolls: Enchant Armor - _scrolls.put(732, new EnchantScroll(false, false, true, CrystalType.A)); - _scrolls.put(950, new EnchantScroll(false, false, true, CrystalType.B)); - _scrolls.put(954, new EnchantScroll(false, false, true, CrystalType.C)); - _scrolls.put(958, new EnchantScroll(false, false, true, CrystalType.D)); - _scrolls.put(962, new EnchantScroll(false, false, true, CrystalType.S)); - } - - /** - * @param scroll The instance of item to make checks on. - * @return enchant template for scroll. - */ - protected static final EnchantScroll getEnchantScroll(ItemInstance scroll) - { - return _scrolls.get(scroll.getItemId()); - } - - /** - * @param item The instance of item to make checks on. - * @return true if item can be enchanted. - */ - protected static final boolean isEnchantable(ItemInstance item) - { - if (item.isHeroItem() || item.isShadowItem() || item.isEtcItem() || item.getItem().getItemType() == WeaponType.FISHINGROD) - return false; - - // only equipped items or in inventory can be enchanted - if (item.getLocation() != ItemInstance.ItemLocation.INVENTORY && item.getLocation() != ItemInstance.ItemLocation.PAPERDOLL) - return false; - - return true; - } -} \ No newline at end of file Index: config/players.properties =================================================================== --- config/players.properties (revision 5) +++ config/players.properties (working copy) @@ -72,30 +72,6 @@ AltGameFreightPrice = 1000 #============================================================= -# Enchant -#============================================================= -# % chance of success to enchant a magic weapon -EnchantChanceMagicWeapon = 0.4 -EnchantChanceMagicWeapon15Plus = 0.2 - -# % chance of success to enchant a non magic weapon -EnchantChanceNonMagicWeapon = 0.7 -EnchantChanceNonMagicWeapon15Plus = 0.35 - -# % chance of success to enchant an armor part (both jewelry or armor) -EnchantChanceArmor = 0.66 - -# Enchant limit [default = 0] -EnchantMaxWeapon = 0 -EnchantMaxArmor = 0 - -# if EnchantSafeMax is set to for ex '8' the item will be safly enchanted to '8' regardless of -# enchant chance(default = 3 for EnchantSafeMax and default = 4 for EnchantSafeMaxFull) -# EnchantSafeMaxFull is for full body armor (upper and lower), value should be > 0. -EnchantSafeMax = 3 -EnchantSafeMaxFull = 4 - -#============================================================= # Augmentations #============================================================= # Control the chance to get a skill in the augmentation process. Index: java/net/sf/l2j/gameserver/datatables/EnchantTable.java =================================================================== --- java/net/sf/l2j/gameserver/datatables/EnchantTable.java (revision 0) +++ java/net/sf/l2j/gameserver/datatables/EnchantTable.java (revision 0) @@ -0,0 +1,117 @@ +/* + * 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 net.sf.l2j.gameserver.datatables; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import net.sf.l2j.gameserver.model.L2EnchantScroll; +import net.sf.l2j.gameserver.model.item.instance.ItemInstance; +import net.sf.l2j.gameserver.model.item.type.CrystalType; +import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +public class EnchantTable +{ + private static Logger _log = Logger.getLogger(EnchantTable.class.getName()); + + private static final Map<Integer, L2EnchantScroll> _map = new HashMap<>(); + + public static EnchantTable getInstance() + { + return SingletonHolder._instance; + } + + protected EnchantTable() + { + try + { + File f = new File("./data/xml/enchants.xml"); + Document doc = XMLDocumentFactory.getInstance().loadDocument(f); + + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) + { + if ("list".equalsIgnoreCase(n.getNodeName())) + { + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) + { + if ("enchant".equalsIgnoreCase(d.getNodeName())) + { + NamedNodeMap attrs = d.getAttributes(); + + int id = Integer.valueOf(attrs.getNamedItem("id").getNodeValue()); + byte grade = Byte.valueOf(attrs.getNamedItem("grade").getNodeValue()); + boolean weapon = Boolean.valueOf(attrs.getNamedItem("weapon").getNodeValue()); + boolean breaks = Boolean.valueOf(attrs.getNamedItem("break").getNodeValue()); + boolean maintain = Boolean.valueOf(attrs.getNamedItem("maintain").getNodeValue()); + + String[] list = attrs.getNamedItem("chance").getNodeValue().split(";"); + byte[] chance = new byte[list.length]; + for (int i = 0; i < list.length; i++) + chance[i] = Byte.valueOf(list[i]); + + CrystalType grade_test = CrystalType.NONE; + switch (grade) + { + case 1: + grade_test = CrystalType.D; + break; + case 2: + grade_test = CrystalType.C; + break; + case 3: + grade_test = CrystalType.B; + break; + case 4: + grade_test = CrystalType.A; + break; + case 5: + grade_test = CrystalType.S; + break; + } + + _map.put(id, new L2EnchantScroll(grade_test, weapon, breaks, maintain, chance)); + } + } + } + } + + _log.info("EnchantTable: Loaded " + _map.size() + " enchants."); + } + catch (Exception e) + { + _log.warning("EnchantTable: Error while loading enchant table: " + e); + } + } + + public L2EnchantScroll getEnchantScroll(ItemInstance item) + { + return _map.get(item.getItemId()); + } + + private static class SingletonHolder + { + protected static final EnchantTable _instance = new EnchantTable(); + } +} Index: java/net/sf/l2j/gameserver/GameServer.java =================================================================== --- java/net/sf/l2j/gameserver/GameServer.java (revision 5) +++ java/net/sf/l2j/gameserver/GameServer.java (working copy) @@ -42,6 +42,7 @@ import net.sf.l2j.gameserver.datatables.CharTemplateTable; import net.sf.l2j.gameserver.datatables.ClanTable; import net.sf.l2j.gameserver.datatables.DoorTable; +import net.sf.l2j.gameserver.datatables.EnchantTable; import net.sf.l2j.gameserver.datatables.FishTable; import net.sf.l2j.gameserver.datatables.GmListTable; import net.sf.l2j.gameserver.datatables.HelperBuffTable; @@ -166,6 +167,7 @@ FishTable.getInstance(); SpellbookTable.getInstance(); SoulCrystalsTable.load(); + EnchantTable.getInstance(); Util.printSection("Augments"); AugmentationData.getInstance(); Index: java/net/sf/l2j/gameserver/model/L2EnchantScroll.java =================================================================== --- java/net/sf/l2j/gameserver/model/L2EnchantScroll.java (revision 0) +++ java/net/sf/l2j/gameserver/model/L2EnchantScroll.java (revision 0) @@ -0,0 +1,104 @@ +/* + * 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 net.sf.l2j.gameserver.model; + +import net.sf.l2j.gameserver.model.item.instance.ItemInstance; +import net.sf.l2j.gameserver.model.item.kind.Item; +import net.sf.l2j.gameserver.model.item.type.CrystalType; + +public class L2EnchantScroll +{ + private final CrystalType _grade; + private final boolean _weapon; + private final boolean _breaks; + private final boolean _maintain; + private final byte[] _chance; + + public L2EnchantScroll(CrystalType grade, boolean weapon, boolean breaks, boolean maintain, byte[] chance) + { + _grade = grade; + _weapon = weapon; + _breaks = breaks; + _maintain = maintain; + _chance = chance; + } + + /** + * @param enchantItem : The item to enchant. + * @return the enchant chance under double format. + */ + public final byte getChance(ItemInstance enchantItem) + { + int level = enchantItem.getEnchantLevel(); + if (enchantItem.getItem().getBodyPart() == Item.SLOT_FULL_ARMOR && level != 0) + level--; + + if (level >= _chance.length) + return 0; + + return _chance[level]; + } + + public final boolean canBreak() + { + return _breaks; + } + + public final boolean canMaintain() + { + return _maintain; + } + + // TODO: methods + + /** + * @param enchantItem : The item to enchant. + * @return True if enchant can be used on selected item. + */ + public final boolean isValid(ItemInstance enchantItem) + { + // check for crystal type + if (_grade != enchantItem.getItem().getCrystalType()) + return false; + + // check enchant max level + if (enchantItem.getEnchantLevel() >= _chance.length) + return false; + + // checking scroll type + switch (enchantItem.getItem().getType2()) + { + case Item.TYPE2_WEAPON: + if (!_weapon) + return false; + break; + + case Item.TYPE2_SHIELD_ARMOR: + case Item.TYPE2_ACCESSORY: + if (_weapon) + return false; + break; + + default: + return false; + } + + return true; + } +} Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java =================================================================== --- java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (revision 5) +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (working copy) @@ -16,7 +16,9 @@ import net.sf.l2j.Config; import net.sf.l2j.gameserver.datatables.ArmorSetsTable; +import net.sf.l2j.gameserver.datatables.EnchantTable; import net.sf.l2j.gameserver.datatables.SkillTable; +import net.sf.l2j.gameserver.model.L2EnchantScroll; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.L2World; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; @@ -25,6 +27,7 @@ import net.sf.l2j.gameserver.model.item.kind.Armor; import net.sf.l2j.gameserver.model.item.kind.Item; import net.sf.l2j.gameserver.model.item.kind.Weapon; +import net.sf.l2j.gameserver.model.item.type.WeaponType; import net.sf.l2j.gameserver.model.itemcontainer.Inventory; import net.sf.l2j.gameserver.network.SystemMessageId; import net.sf.l2j.gameserver.network.serverpackets.EnchantResult; @@ -35,7 +38,7 @@ import net.sf.l2j.gameserver.util.Util; import net.sf.l2j.util.Rnd; -public final class RequestEnchantItem extends AbstractEnchantPacket +public final class RequestEnchantItem extends L2GameClientPacket { private int _objectId = 0; @@ -48,16 +51,19 @@ @Override protected void runImpl() { + // get player final L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null || _objectId == 0) return; + // player online and active if (!activeChar.isOnline() || getClient().isDetached()) { activeChar.setActiveEnchantItem(null); return; } + // player on shop/craft if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode()) { activeChar.sendPacket(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE); @@ -65,7 +71,18 @@ activeChar.sendPacket(EnchantResult.CANCELLED); return; } + + // player trading + if (activeChar.getActiveTradeList() != null) + { + activeChar.cancelActiveTrade(); + activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED); + activeChar.setActiveEnchantItem(null); + activeChar.sendPacket(EnchantResult.CANCELLED); + return; + } + // get item and enchant scroll ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId); ItemInstance scroll = activeChar.getActiveEnchantItem(); @@ -77,13 +94,13 @@ return; } - // template for scroll - EnchantScroll scrollTemplate = getEnchantScroll(scroll); - if (scrollTemplate == null) + // get scroll enchant data + L2EnchantScroll enchant = EnchantTable.getInstance().getEnchantScroll(scroll); + if (enchant == null) return; - // first validation check - if (!scrollTemplate.isValid(item) || !isEnchantable(item)) + // validation check + if (!isEnchantable(item) || !enchant.isValid(item) || item.getOwnerId() != activeChar.getObjectId()) { activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION); activeChar.setActiveEnchantItem(null); @@ -91,7 +108,7 @@ return; } - // attempting to destroy scroll + // destroy enchant scroll scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, activeChar, item); if (scroll == null) { @@ -102,46 +119,27 @@ return; } - if (activeChar.getActiveTradeList() != null) - { - activeChar.cancelActiveTrade(); - activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED); - return; - } - synchronized (item) { - double chance = scrollTemplate.getChance(item); - - // last validation check - if (item.getOwnerId() != activeChar.getObjectId() || !isEnchantable(item) || chance < 0) - { - activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION); - activeChar.setActiveEnchantItem(null); - activeChar.sendPacket(EnchantResult.CANCELLED); - return; - } - // success - if (Rnd.get() < chance) + if (Rnd.get(100) < enchant.getChance(item)) { - // announce the success + // send message SystemMessage sm; if (item.getEnchantLevel() == 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESSFULLY_ENCHANTED); - sm.addItemName(item.getItemId()); - activeChar.sendPacket(sm); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_SUCCESSFULLY_ENCHANTED); sm.addNumber(item.getEnchantLevel()); - sm.addItemName(item.getItemId()); - activeChar.sendPacket(sm); } + sm.addItemName(item.getItemId()); + // update item item.setEnchantLevel(item.getEnchantLevel() + 1); item.updateDatabase(); @@ -186,6 +184,7 @@ } activeChar.sendPacket(EnchantResult.SUCCESS); } + // fail else { // Drop passive skills from items. @@ -228,39 +227,46 @@ } } - if (scrollTemplate.isBlessed()) + if (!enchant.canBreak()) { - // blessed enchant - clear enchant value + // keep item activeChar.sendPacket(SystemMessageId.BLESSED_ENCHANT_FAILED); - item.setEnchantLevel(0); - item.updateDatabase(); + if (!enchant.canMaintain()) + { + item.setEnchantLevel(0); + item.updateDatabase(); + } activeChar.sendPacket(EnchantResult.UNSUCCESS); } else { - // enchant failed, destroy item - int crystalId = item.getItem().getCrystalItemId(); - int count = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2; - if (count < 1) - count = 1; - + // destroy item ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null); if (destroyItem == null) { - // unable to destroy item, cheater ? Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH); activeChar.setActiveEnchantItem(null); activeChar.sendPacket(EnchantResult.CANCELLED); return; } - if (crystalId != 0) + // add crystals, if item crystalizable + int crystalType = item.getItem().getCrystalItemId(); + ItemInstance crystals = null; + if (crystalType != 0) { - activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem); - activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(crystalId).addItemNumber(count)); + // get crystals count + int crystalCount = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2; + if (crystalCount < 1) + crystalCount = 1; + + // add crystals to inventory + crystals = activeChar.getInventory().addItem("Enchant", crystalType, crystalCount, activeChar, destroyItem); + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(crystals.getItemId()).addItemNumber(crystalCount)); } + // update inventory InventoryUpdate iu = new InventoryUpdate(); if (destroyItem.getCount() == 0) iu.addRemovedItem(destroyItem); @@ -269,27 +275,49 @@ activeChar.sendPacket(iu); - // Messages. + // remove item + L2World.getInstance().removeObject(destroyItem); + + // send message if (item.getEnchantLevel() > 0) activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_FAILED_S1_S2_EVAPORATED).addNumber(item.getEnchantLevel()).addItemName(item.getItemId())); else activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_FAILED_S1_EVAPORATED).addItemName(item.getItemId())); - L2World.getInstance().removeObject(destroyItem); - if (crystalId == 0) + // send enchant result + if (crystalType == 0) activeChar.sendPacket(EnchantResult.UNK_RESULT_4); else activeChar.sendPacket(EnchantResult.UNK_RESULT_1); + // update weight StatusUpdate su = new StatusUpdate(activeChar); su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad()); activeChar.sendPacket(su); } } + // send item list activeChar.sendPacket(new ItemList(activeChar, false)); + + // update appearance activeChar.broadcastUserInfo(); activeChar.setActiveEnchantItem(null); } } + /** + * @param item The instance of item to make checks on. + * @return true if item can be enchanted. + */ + private static final boolean isEnchantable(ItemInstance item) + { + if (item.isHeroItem() || item.isShadowItem() || item.isEtcItem() || item.getItem().getItemType() == WeaponType.FISHINGROD) + return false; + + // only equipped items or in inventory can be enchanted + if (item.getLocation() != ItemInstance.ItemLocation.INVENTORY && item.getLocation() != ItemInstance.ItemLocation.PAPERDOLL) + return false; + + return true; + } } \ No newline at end of file Index: java/net/sf/l2j/Config.java =================================================================== --- java/net/sf/l2j/Config.java (revision 5) +++ java/net/sf/l2j/Config.java (working copy) @@ -405,17 +405,6 @@ public static boolean ALT_GAME_FREIGHTS; public static int ALT_GAME_FREIGHT_PRICE; - /** Enchant */ - public static double ENCHANT_CHANCE_WEAPON_MAGIC; - public static double ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS; - public static double ENCHANT_CHANCE_WEAPON_NONMAGIC; - public static double ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS; - public static double ENCHANT_CHANCE_ARMOR; - public static int ENCHANT_MAX_WEAPON; - public static int ENCHANT_MAX_ARMOR; - public static int ENCHANT_SAFE_MAX; - public static int ENCHANT_SAFE_MAX_FULL; - /** Augmentations */ public static int AUGMENTATION_NG_SKILL_CHANCE; public static int AUGMENTATION_NG_GLOW_CHANCE; @@ -1020,16 +1009,6 @@ ALT_GAME_FREIGHTS = players.getProperty("AltGameFreights", false); ALT_GAME_FREIGHT_PRICE = players.getProperty("AltGameFreightPrice", 1000); - ENCHANT_CHANCE_WEAPON_MAGIC = players.getProperty("EnchantChanceMagicWeapon", 0.4); - ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS = players.getProperty("EnchantChanceMagicWeapon15Plus", 0.2); - ENCHANT_CHANCE_WEAPON_NONMAGIC = players.getProperty("EnchantChanceNonMagicWeapon", 0.7); - ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS = players.getProperty("EnchantChanceNonMagicWeapon15Plus", 0.35); - ENCHANT_CHANCE_ARMOR = players.getProperty("EnchantChanceArmor", 0.66); - ENCHANT_MAX_WEAPON = players.getProperty("EnchantMaxWeapon", 0); - ENCHANT_MAX_ARMOR = players.getProperty("EnchantMaxArmor", 0); - ENCHANT_SAFE_MAX = players.getProperty("EnchantSafeMax", 3); - ENCHANT_SAFE_MAX_FULL = players.getProperty("EnchantSafeMaxFull", 4); - AUGMENTATION_NG_SKILL_CHANCE = players.getProperty("AugmentationNGSkillChance", 15); AUGMENTATION_NG_GLOW_CHANCE = players.getProperty("AugmentationNGGlowChance", 0); AUGMENTATION_MID_SKILL_CHANCE = players.getProperty("AugmentationMidSkillChance", 30); -
Hello how would you put a scroll to all grids? I can not set the scroll grid for all. ### Eclipse Workspace Patch 1.0 #P aCis_datapack Index: data/xml/enchants.xml =================================================================== --- data/xml/enchants.xml (revision 0) +++ data/xml/enchants.xml (revision 0) @@ -0,0 +1,44 @@ +<?xml version='1.0' encoding='utf-8'?> +<list> + <!-- Scrolls: Enchant Weapon --> + <enchant id="959" grade="5" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Scrolls: Enchant Weapon --> + <enchant id="729" grade="4" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Scrolls: Enchant Weapon --> + <enchant id="947" grade="3" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Scrolls: Enchant Weapon --> + <enchant id="951" grade="2" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Scrolls: Enchant Weapon --> + <enchant id="955" grade="1" weapon="True" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Scrolls: Enchant Weapon --> + + <!-- Scrolls: Enchant Armor --> + <enchant id="960" grade="5" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Scrolls: Enchant Armor --> + <enchant id="730" grade="4" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Scrolls: Enchant Armor --> + <enchant id="948" grade="3" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Scrolls: Enchant Armor --> + <enchant id="952" grade="2" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Scrolls: Enchant Armor --> + <enchant id="956" grade="1" weapon="False" break="True" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Scrolls: Enchant Armor --> + + <!-- Blessed Scrolls: Enchant Weapon --> + <enchant id="6577" grade="5" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6569" grade="4" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6571" grade="3" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6573" grade="2" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Blessed Scrolls: Enchant Weapon --> + <enchant id="6575" grade="1" weapon="True" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Blessed Scrolls: Enchant Weapon --> + + <!-- Blessed Scrolls: Armor Weapon --> + <enchant id="6578" grade="5" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6570" grade="4" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6572" grade="3" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6574" grade="2" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Blessed Scrolls: Enchant Armor --> + <enchant id="6576" grade="1" weapon="False" break="False" maintain="False" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Blessed Scrolls: Enchant Armor --> + + <!-- Crystal Scrolls: Enchant Weapon --> + <enchant id="961" grade="5" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="731" grade="4" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="949" grade="3" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="953" grade="2" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="957" grade="1" weapon="True" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Crystal Scrolls: Enchant Weapon --> + + <!-- Crystal Scrolls: Enchant Armor --> + <enchant id="962" grade="5" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- S grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="732" grade="4" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- A grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="950" grade="3" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- B grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="954" grade="2" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- C grade - Crystal Scrolls: Enchant Weapon --> + <enchant id="958" grade="1" weapon="False" break="False" maintain="True" chance="100;100;100;95;90;85;80;75" /> <!-- D grade - Crystal Scrolls: Enchant Weapon --> +</list> \ No newline at end of file #P aCis_gameserver Index: java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java =================================================================== --- java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java (revision 5) +++ java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java (working copy) @@ -1,212 +0,0 @@ -/* - * 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 net.sf.l2j.gameserver.network.clientpackets; - -import java.util.HashMap; -import java.util.Map; - -import net.sf.l2j.Config; -import net.sf.l2j.gameserver.model.item.instance.ItemInstance; -import net.sf.l2j.gameserver.model.item.kind.Item; -import net.sf.l2j.gameserver.model.item.kind.Weapon; -import net.sf.l2j.gameserver.model.item.type.CrystalType; -import net.sf.l2j.gameserver.model.item.type.WeaponType; - -public abstract class AbstractEnchantPacket extends L2GameClientPacket -{ - public static final Map<Integer, EnchantScroll> _scrolls = new HashMap<>(); - - public static final class EnchantScroll - { - protected final boolean _isWeapon; - protected final CrystalType _grade; - private final boolean _isBlessed; - private final boolean _isCrystal; - - public EnchantScroll(boolean wep, boolean bless, boolean crystal, CrystalType type) - { - _isWeapon = wep; - _grade = type; - _isBlessed = bless; - _isCrystal = crystal; - } - - /** - * @param enchantItem : The item to enchant. - * @return true if support item can be used for this item - */ - public final boolean isValid(ItemInstance enchantItem) - { - if (enchantItem == null) - return false; - - // checking scroll type and configured maximum enchant level - switch (enchantItem.getItem().getType2()) - { - case Item.TYPE2_WEAPON: - if (!_isWeapon || (Config.ENCHANT_MAX_WEAPON > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON)) - return false; - break; - - case Item.TYPE2_SHIELD_ARMOR: - case Item.TYPE2_ACCESSORY: - if (_isWeapon || (Config.ENCHANT_MAX_ARMOR > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR)) - return false; - break; - - default: - return false; - } - - // check for crystal type - if (_grade != enchantItem.getItem().getCrystalType()) - return false; - - return true; - } - - /** - * @return true if item is a blessed scroll. - */ - public final boolean isBlessed() - { - return _isBlessed; - } - - /** - * @return true if item is a crystal scroll. - */ - public final boolean isCrystal() - { - return _isCrystal; - } - - /** - * Regarding enchant system :<br> - * <br> - * <u>Weapons</u> - * <ul> - * <li>magic weapons has chance of 40% until +15 and 20% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li> - * <li>non magic weapons has chance of 70% until +15 and 35% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li> - * </ul> - * <u>Armors</u> - * <ul> - * <li>non fullbody armors (jewelry, upper armor, lower armor, boots, gloves, helmets and shirts) has chance of 2/3 for +4, 1/3 for +5, 1/4 for +6, ...., 1/18 +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li> - * <li>full body armors has a chance of 1/1 for +4, 2/3 for +5, 1/3 for +6, ..., 1/17 for +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li> - * </ul> - * @param enchantItem : The item to enchant. - * @return the enchant chance under double format (0.7 / 0.35 / 0.44324...). - */ - public final double getChance(ItemInstance enchantItem) - { - if (!isValid(enchantItem)) - return -1; - - boolean fullBody = enchantItem.getItem().getBodyPart() == Item.SLOT_FULL_ARMOR; - if (enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX || (fullBody && enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX_FULL)) - return 1; - - double chance = 0; - - // Armor formula : 0.66^(current-2), chance is lower and lower for each enchant. - if (enchantItem.isArmor()) - chance = Math.pow(Config.ENCHANT_CHANCE_ARMOR, (enchantItem.getEnchantLevel() - 2)); - // Weapon formula is 70% for fighter weapon, 40% for mage weapon. Special rates after +14. - else if (enchantItem.isWeapon()) - { - if (((Weapon) enchantItem.getItem()).isMagical()) - chance = (enchantItem.getEnchantLevel() > 14) ? Config.ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS : Config.ENCHANT_CHANCE_WEAPON_MAGIC; - else - chance = (enchantItem.getEnchantLevel() > 14) ? Config.ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS : Config.ENCHANT_CHANCE_WEAPON_NONMAGIC; - } - - return chance; - } - } - - /** - * Format : itemId, (isWeapon, isBlessed, isCrystal, grade)<br> - * Allowed items IDs must be sorted by ascending order. - */ - static - { - // Scrolls: Enchant Weapon - _scrolls.put(729, new EnchantScroll(true, false, false, CrystalType.A)); - _scrolls.put(947, new EnchantScroll(true, false, false, CrystalType.B)); - _scrolls.put(951, new EnchantScroll(true, false, false, CrystalType.C)); - _scrolls.put(955, new EnchantScroll(true, false, false, CrystalType.D)); - _scrolls.put(959, new EnchantScroll(true, false, false, CrystalType.S)); - - // Scrolls: Enchant Armor - _scrolls.put(730, new EnchantScroll(false, false, false, CrystalType.A)); - _scrolls.put(948, new EnchantScroll(false, false, false, CrystalType.B)); - _scrolls.put(952, new EnchantScroll(false, false, false, CrystalType.C)); - _scrolls.put(956, new EnchantScroll(false, false, false, CrystalType.D)); - _scrolls.put(960, new EnchantScroll(false, false, false, CrystalType.S)); - - // Blessed Scrolls: Enchant Weapon - _scrolls.put(6569, new EnchantScroll(true, true, false, CrystalType.A)); - _scrolls.put(6571, new EnchantScroll(true, true, false, CrystalType.B)); - _scrolls.put(6573, new EnchantScroll(true, true, false, CrystalType.C)); - _scrolls.put(6575, new EnchantScroll(true, true, false, CrystalType.D)); - _scrolls.put(6577, new EnchantScroll(true, true, false, CrystalType.S)); - - // Blessed Scrolls: Enchant Armor - _scrolls.put(6570, new EnchantScroll(false, true, false, CrystalType.A)); - _scrolls.put(6572, new EnchantScroll(false, true, false, CrystalType.B)); - _scrolls.put(6574, new EnchantScroll(false, true, false, CrystalType.C)); - _scrolls.put(6576, new EnchantScroll(false, true, false, CrystalType.D)); - _scrolls.put(6578, new EnchantScroll(false, true, false, CrystalType.S)); - - // Crystal Scrolls: Enchant Weapon - _scrolls.put(731, new EnchantScroll(true, false, true, CrystalType.A)); - _scrolls.put(949, new EnchantScroll(true, false, true, CrystalType.B)); - _scrolls.put(953, new EnchantScroll(true, false, true, CrystalType.C)); - _scrolls.put(957, new EnchantScroll(true, false, true, CrystalType.D)); - _scrolls.put(961, new EnchantScroll(true, false, true, CrystalType.S)); - - // Crystal Scrolls: Enchant Armor - _scrolls.put(732, new EnchantScroll(false, false, true, CrystalType.A)); - _scrolls.put(950, new EnchantScroll(false, false, true, CrystalType.B)); - _scrolls.put(954, new EnchantScroll(false, false, true, CrystalType.C)); - _scrolls.put(958, new EnchantScroll(false, false, true, CrystalType.D)); - _scrolls.put(962, new EnchantScroll(false, false, true, CrystalType.S)); - } - - /** - * @param scroll The instance of item to make checks on. - * @return enchant template for scroll. - */ - protected static final EnchantScroll getEnchantScroll(ItemInstance scroll) - { - return _scrolls.get(scroll.getItemId()); - } - - /** - * @param item The instance of item to make checks on. - * @return true if item can be enchanted. - */ - protected static final boolean isEnchantable(ItemInstance item) - { - if (item.isHeroItem() || item.isShadowItem() || item.isEtcItem() || item.getItem().getItemType() == WeaponType.FISHINGROD) - return false; - - // only equipped items or in inventory can be enchanted - if (item.getLocation() != ItemInstance.ItemLocation.INVENTORY && item.getLocation() != ItemInstance.ItemLocation.PAPERDOLL) - return false; - - return true; - } -} \ No newline at end of file Index: config/players.properties =================================================================== --- config/players.properties (revision 5) +++ config/players.properties (working copy) @@ -72,30 +72,6 @@ AltGameFreightPrice = 1000 #============================================================= -# Enchant -#============================================================= -# % chance of success to enchant a magic weapon -EnchantChanceMagicWeapon = 0.4 -EnchantChanceMagicWeapon15Plus = 0.2 - -# % chance of success to enchant a non magic weapon -EnchantChanceNonMagicWeapon = 0.7 -EnchantChanceNonMagicWeapon15Plus = 0.35 - -# % chance of success to enchant an armor part (both jewelry or armor) -EnchantChanceArmor = 0.66 - -# Enchant limit [default = 0] -EnchantMaxWeapon = 0 -EnchantMaxArmor = 0 - -# if EnchantSafeMax is set to for ex '8' the item will be safly enchanted to '8' regardless of -# enchant chance(default = 3 for EnchantSafeMax and default = 4 for EnchantSafeMaxFull) -# EnchantSafeMaxFull is for full body armor (upper and lower), value should be > 0. -EnchantSafeMax = 3 -EnchantSafeMaxFull = 4 - -#============================================================= # Augmentations #============================================================= # Control the chance to get a skill in the augmentation process. Index: java/net/sf/l2j/gameserver/datatables/EnchantTable.java =================================================================== --- java/net/sf/l2j/gameserver/datatables/EnchantTable.java (revision 0) +++ java/net/sf/l2j/gameserver/datatables/EnchantTable.java (revision 0) @@ -0,0 +1,117 @@ +/* + * 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 net.sf.l2j.gameserver.datatables; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import net.sf.l2j.gameserver.model.L2EnchantScroll; +import net.sf.l2j.gameserver.model.item.instance.ItemInstance; +import net.sf.l2j.gameserver.model.item.type.CrystalType; +import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +public class EnchantTable +{ + private static Logger _log = Logger.getLogger(EnchantTable.class.getName()); + + private static final Map<Integer, L2EnchantScroll> _map = new HashMap<>(); + + public static EnchantTable getInstance() + { + return SingletonHolder._instance; + } + + protected EnchantTable() + { + try + { + File f = new File("./data/xml/enchants.xml"); + Document doc = XMLDocumentFactory.getInstance().loadDocument(f); + + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) + { + if ("list".equalsIgnoreCase(n.getNodeName())) + { + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) + { + if ("enchant".equalsIgnoreCase(d.getNodeName())) + { + NamedNodeMap attrs = d.getAttributes(); + + int id = Integer.valueOf(attrs.getNamedItem("id").getNodeValue()); + byte grade = Byte.valueOf(attrs.getNamedItem("grade").getNodeValue()); + boolean weapon = Boolean.valueOf(attrs.getNamedItem("weapon").getNodeValue()); + boolean breaks = Boolean.valueOf(attrs.getNamedItem("break").getNodeValue()); + boolean maintain = Boolean.valueOf(attrs.getNamedItem("maintain").getNodeValue()); + + String[] list = attrs.getNamedItem("chance").getNodeValue().split(";"); + byte[] chance = new byte[list.length]; + for (int i = 0; i < list.length; i++) + chance[i] = Byte.valueOf(list[i]); + + CrystalType grade_test = CrystalType.NONE; + switch (grade) + { + case 1: + grade_test = CrystalType.D; + break; + case 2: + grade_test = CrystalType.C; + break; + case 3: + grade_test = CrystalType.B; + break; + case 4: + grade_test = CrystalType.A; + break; + case 5: + grade_test = CrystalType.S; + break; + } + + _map.put(id, new L2EnchantScroll(grade_test, weapon, breaks, maintain, chance)); + } + } + } + } + + _log.info("EnchantTable: Loaded " + _map.size() + " enchants."); + } + catch (Exception e) + { + _log.warning("EnchantTable: Error while loading enchant table: " + e); + } + } + + public L2EnchantScroll getEnchantScroll(ItemInstance item) + { + return _map.get(item.getItemId()); + } + + private static class SingletonHolder + { + protected static final EnchantTable _instance = new EnchantTable(); + } +} Index: java/net/sf/l2j/gameserver/GameServer.java =================================================================== --- java/net/sf/l2j/gameserver/GameServer.java (revision 5) +++ java/net/sf/l2j/gameserver/GameServer.java (working copy) @@ -42,6 +42,7 @@ import net.sf.l2j.gameserver.datatables.CharTemplateTable; import net.sf.l2j.gameserver.datatables.ClanTable; import net.sf.l2j.gameserver.datatables.DoorTable; +import net.sf.l2j.gameserver.datatables.EnchantTable; import net.sf.l2j.gameserver.datatables.FishTable; import net.sf.l2j.gameserver.datatables.GmListTable; import net.sf.l2j.gameserver.datatables.HelperBuffTable; @@ -166,6 +167,7 @@ FishTable.getInstance(); SpellbookTable.getInstance(); SoulCrystalsTable.load(); + EnchantTable.getInstance(); Util.printSection("Augments"); AugmentationData.getInstance(); Index: java/net/sf/l2j/gameserver/model/L2EnchantScroll.java =================================================================== --- java/net/sf/l2j/gameserver/model/L2EnchantScroll.java (revision 0) +++ java/net/sf/l2j/gameserver/model/L2EnchantScroll.java (revision 0) @@ -0,0 +1,104 @@ +/* + * 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 net.sf.l2j.gameserver.model; + +import net.sf.l2j.gameserver.model.item.instance.ItemInstance; +import net.sf.l2j.gameserver.model.item.kind.Item; +import net.sf.l2j.gameserver.model.item.type.CrystalType; + +public class L2EnchantScroll +{ + private final CrystalType _grade; + private final boolean _weapon; + private final boolean _breaks; + private final boolean _maintain; + private final byte[] _chance; + + public L2EnchantScroll(CrystalType grade, boolean weapon, boolean breaks, boolean maintain, byte[] chance) + { + _grade = grade; + _weapon = weapon; + _breaks = breaks; + _maintain = maintain; + _chance = chance; + } + + /** + * @param enchantItem : The item to enchant. + * @return the enchant chance under double format. + */ + public final byte getChance(ItemInstance enchantItem) + { + int level = enchantItem.getEnchantLevel(); + if (enchantItem.getItem().getBodyPart() == Item.SLOT_FULL_ARMOR && level != 0) + level--; + + if (level >= _chance.length) + return 0; + + return _chance[level]; + } + + public final boolean canBreak() + { + return _breaks; + } + + public final boolean canMaintain() + { + return _maintain; + } + + // TODO: methods + + /** + * @param enchantItem : The item to enchant. + * @return True if enchant can be used on selected item. + */ + public final boolean isValid(ItemInstance enchantItem) + { + // check for crystal type + if (_grade != enchantItem.getItem().getCrystalType()) + return false; + + // check enchant max level + if (enchantItem.getEnchantLevel() >= _chance.length) + return false; + + // checking scroll type + switch (enchantItem.getItem().getType2()) + { + case Item.TYPE2_WEAPON: + if (!_weapon) + return false; + break; + + case Item.TYPE2_SHIELD_ARMOR: + case Item.TYPE2_ACCESSORY: + if (_weapon) + return false; + break; + + default: + return false; + } + + return true; + } +} Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java =================================================================== --- java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (revision 5) +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (working copy) @@ -16,7 +16,9 @@ import net.sf.l2j.Config; import net.sf.l2j.gameserver.datatables.ArmorSetsTable; +import net.sf.l2j.gameserver.datatables.EnchantTable; import net.sf.l2j.gameserver.datatables.SkillTable; +import net.sf.l2j.gameserver.model.L2EnchantScroll; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.L2World; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; @@ -25,6 +27,7 @@ import net.sf.l2j.gameserver.model.item.kind.Armor; import net.sf.l2j.gameserver.model.item.kind.Item; import net.sf.l2j.gameserver.model.item.kind.Weapon; +import net.sf.l2j.gameserver.model.item.type.WeaponType; import net.sf.l2j.gameserver.model.itemcontainer.Inventory; import net.sf.l2j.gameserver.network.SystemMessageId; import net.sf.l2j.gameserver.network.serverpackets.EnchantResult; @@ -35,7 +38,7 @@ import net.sf.l2j.gameserver.util.Util; import net.sf.l2j.util.Rnd; -public final class RequestEnchantItem extends AbstractEnchantPacket +public final class RequestEnchantItem extends L2GameClientPacket { private int _objectId = 0; @@ -48,16 +51,19 @@ @Override protected void runImpl() { + // get player final L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null || _objectId == 0) return; + // player online and active if (!activeChar.isOnline() || getClient().isDetached()) { activeChar.setActiveEnchantItem(null); return; } + // player on shop/craft if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode()) { activeChar.sendPacket(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE); @@ -65,7 +71,18 @@ activeChar.sendPacket(EnchantResult.CANCELLED); return; } + + // player trading + if (activeChar.getActiveTradeList() != null) + { + activeChar.cancelActiveTrade(); + activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED); + activeChar.setActiveEnchantItem(null); + activeChar.sendPacket(EnchantResult.CANCELLED); + return; + } + // get item and enchant scroll ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId); ItemInstance scroll = activeChar.getActiveEnchantItem(); @@ -77,13 +94,13 @@ return; } - // template for scroll - EnchantScroll scrollTemplate = getEnchantScroll(scroll); - if (scrollTemplate == null) + // get scroll enchant data + L2EnchantScroll enchant = EnchantTable.getInstance().getEnchantScroll(scroll); + if (enchant == null) return; - // first validation check - if (!scrollTemplate.isValid(item) || !isEnchantable(item)) + // validation check + if (!isEnchantable(item) || !enchant.isValid(item) || item.getOwnerId() != activeChar.getObjectId()) { activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION); activeChar.setActiveEnchantItem(null); @@ -91,7 +108,7 @@ return; } - // attempting to destroy scroll + // destroy enchant scroll scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, activeChar, item); if (scroll == null) { @@ -102,46 +119,27 @@ return; } - if (activeChar.getActiveTradeList() != null) - { - activeChar.cancelActiveTrade(); - activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED); - return; - } - synchronized (item) { - double chance = scrollTemplate.getChance(item); - - // last validation check - if (item.getOwnerId() != activeChar.getObjectId() || !isEnchantable(item) || chance < 0) - { - activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION); - activeChar.setActiveEnchantItem(null); - activeChar.sendPacket(EnchantResult.CANCELLED); - return; - } - // success - if (Rnd.get() < chance) + if (Rnd.get(100) < enchant.getChance(item)) { - // announce the success + // send message SystemMessage sm; if (item.getEnchantLevel() == 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESSFULLY_ENCHANTED); - sm.addItemName(item.getItemId()); - activeChar.sendPacket(sm); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_SUCCESSFULLY_ENCHANTED); sm.addNumber(item.getEnchantLevel()); - sm.addItemName(item.getItemId()); - activeChar.sendPacket(sm); } + sm.addItemName(item.getItemId()); + // update item item.setEnchantLevel(item.getEnchantLevel() + 1); item.updateDatabase(); @@ -186,6 +184,7 @@ } activeChar.sendPacket(EnchantResult.SUCCESS); } + // fail else { // Drop passive skills from items. @@ -228,39 +227,46 @@ } } - if (scrollTemplate.isBlessed()) + if (!enchant.canBreak()) { - // blessed enchant - clear enchant value + // keep item activeChar.sendPacket(SystemMessageId.BLESSED_ENCHANT_FAILED); - item.setEnchantLevel(0); - item.updateDatabase(); + if (!enchant.canMaintain()) + { + item.setEnchantLevel(0); + item.updateDatabase(); + } activeChar.sendPacket(EnchantResult.UNSUCCESS); } else { - // enchant failed, destroy item - int crystalId = item.getItem().getCrystalItemId(); - int count = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2; - if (count < 1) - count = 1; - + // destroy item ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null); if (destroyItem == null) { - // unable to destroy item, cheater ? Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH); activeChar.setActiveEnchantItem(null); activeChar.sendPacket(EnchantResult.CANCELLED); return; } - if (crystalId != 0) + // add crystals, if item crystalizable + int crystalType = item.getItem().getCrystalItemId(); + ItemInstance crystals = null; + if (crystalType != 0) { - activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem); - activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(crystalId).addItemNumber(count)); + // get crystals count + int crystalCount = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2; + if (crystalCount < 1) + crystalCount = 1; + + // add crystals to inventory + crystals = activeChar.getInventory().addItem("Enchant", crystalType, crystalCount, activeChar, destroyItem); + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(crystals.getItemId()).addItemNumber(crystalCount)); } + // update inventory InventoryUpdate iu = new InventoryUpdate(); if (destroyItem.getCount() == 0) iu.addRemovedItem(destroyItem); @@ -269,27 +275,49 @@ activeChar.sendPacket(iu); - // Messages. + // remove item + L2World.getInstance().removeObject(destroyItem); + + // send message if (item.getEnchantLevel() > 0) activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_FAILED_S1_S2_EVAPORATED).addNumber(item.getEnchantLevel()).addItemName(item.getItemId())); else activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_FAILED_S1_EVAPORATED).addItemName(item.getItemId())); - L2World.getInstance().removeObject(destroyItem); - if (crystalId == 0) + // send enchant result + if (crystalType == 0) activeChar.sendPacket(EnchantResult.UNK_RESULT_4); else activeChar.sendPacket(EnchantResult.UNK_RESULT_1); + // update weight StatusUpdate su = new StatusUpdate(activeChar); su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad()); activeChar.sendPacket(su); } } + // send item list activeChar.sendPacket(new ItemList(activeChar, false)); + + // update appearance activeChar.broadcastUserInfo(); activeChar.setActiveEnchantItem(null); } } + /** + * @param item The instance of item to make checks on. + * @return true if item can be enchanted. + */ + private static final boolean isEnchantable(ItemInstance item) + { + if (item.isHeroItem() || item.isShadowItem() || item.isEtcItem() || item.getItem().getItemType() == WeaponType.FISHINGROD) + return false; + + // only equipped items or in inventory can be enchanted + if (item.getLocation() != ItemInstance.ItemLocation.INVENTORY && item.getLocation() != ItemInstance.ItemLocation.PAPERDOLL) + return false; + + return true; + } } \ No newline at end of file Index: java/net/sf/l2j/Config.java =================================================================== --- java/net/sf/l2j/Config.java (revision 5) +++ java/net/sf/l2j/Config.java (working copy) @@ -405,17 +405,6 @@ public static boolean ALT_GAME_FREIGHTS; public static int ALT_GAME_FREIGHT_PRICE; - /** Enchant */ - public static double ENCHANT_CHANCE_WEAPON_MAGIC; - public static double ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS; - public static double ENCHANT_CHANCE_WEAPON_NONMAGIC; - public static double ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS; - public static double ENCHANT_CHANCE_ARMOR; - public static int ENCHANT_MAX_WEAPON; - public static int ENCHANT_MAX_ARMOR; - public static int ENCHANT_SAFE_MAX; - public static int ENCHANT_SAFE_MAX_FULL; - /** Augmentations */ public static int AUGMENTATION_NG_SKILL_CHANCE; public static int AUGMENTATION_NG_GLOW_CHANCE; @@ -1020,16 +1009,6 @@ ALT_GAME_FREIGHTS = players.getProperty("AltGameFreights", false); ALT_GAME_FREIGHT_PRICE = players.getProperty("AltGameFreightPrice", 1000); - ENCHANT_CHANCE_WEAPON_MAGIC = players.getProperty("EnchantChanceMagicWeapon", 0.4); - ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS = players.getProperty("EnchantChanceMagicWeapon15Plus", 0.2); - ENCHANT_CHANCE_WEAPON_NONMAGIC = players.getProperty("EnchantChanceNonMagicWeapon", 0.7); - ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS = players.getProperty("EnchantChanceNonMagicWeapon15Plus", 0.35); - ENCHANT_CHANCE_ARMOR = players.getProperty("EnchantChanceArmor", 0.66); - ENCHANT_MAX_WEAPON = players.getProperty("EnchantMaxWeapon", 0); - ENCHANT_MAX_ARMOR = players.getProperty("EnchantMaxArmor", 0); - ENCHANT_SAFE_MAX = players.getProperty("EnchantSafeMax", 3); - ENCHANT_SAFE_MAX_FULL = players.getProperty("EnchantSafeMaxFull", 4); - AUGMENTATION_NG_SKILL_CHANCE = players.getProperty("AugmentationNGSkillChance", 15); AUGMENTATION_NG_GLOW_CHANCE = players.getProperty("AugmentationNGGlowChance", 0); AUGMENTATION_MID_SKILL_CHANCE = players.getProperty("AugmentationMidSkillChance", 30);
-
and I saw this on WareHouse if (player.getActiveEnchantItem() != null) { player.setActiveEnchantItem(null); player.sendPacket(EnchantResult.CANCELLED); player.sendPacket(SystemMessageId.ENCHANT_SCROLL_CANCELLED); }
-
Hello, I'm creating a code to not enchant next to some npcs. But I have this error and I do not see any error in my code. is giving this on gameserver List<Creature> knowns = activeChar.getKnownTypeInRadius(Creature.class, 400); for (WorldObject wh1 : knowns) { String mobtype = ((Npc) knowns).getTemplate().getType(); <!--line 57 is--> if (wh1 instanceof Npc && Config.ENCHANT_PROTECTOR) { if (!Config.LIST_ALLOWED_NPC_TYPES_NOT_ENCHANT.contains(mobtype)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2); sm.addString("Npc Type " + mobtype + " has Protection - Can not You can enchant!"); activeChar.sendPacket(sm); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } } } sorry for the topic, I'm a customer of acis but do not help about custom mods
-
resolved close topic
