Jump to content
  • 0

Question

Posted (edited)

Hi, maybe someone have added trance rebirth system to acis 368? because i have some java error with getAllSkill command in L2RebirthInstance.java and SkillTreeTable.java. I try to change it to getSkill only but no help.

can anyone explain me how to fix it? or add code here. :) tnx  i mark problem red.

 

 

/*
 * 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.actor.instance;

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

import net.sf.l2j.Config;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.model.base.Experience;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;

/**
 * Rebirth Manager
 * @author Trance
 * @skype chr.trance
 */
public final class L2RebirthInstance extends Folk
{
       private static HashMap<Integer, Integer> _rebirthInfo = new HashMap<>();
      
       public L2RebirthInstance(int objectId, NpcTemplate template)
       {
               super(objectId, template);
       }
      
       @Override
       public void onBypassFeedback(Player player, String command)
       {
               if (command.startsWith("performRebirth"))
               {
                       // Maximum rebirth count. Return the player's current Rebirth Level.
                       int currBirth = getRebirthLevel(player);
                       if (currBirth >= Config.REBIRTH_MAX)
                       {
                               NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
                               html.setFile("data/html/managers/rebirth-max.htm");
                              
                               player.sendPacket(html);
                               return;
                       }
                      
                       // Level requirement for a rebirth.
                       if (player.getLevel() < Config.REBIRTH_MIN_LEVEL)
                       {
                               NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
                               html.setFile("data/html/managers/rebirth-level.htm");
                              
                               player.sendPacket(html);
                               return;
                       }
                      
                       int itemId = 0, itemCount = 0, loopBirth = 0;
                       for (String readItems : Config.REBIRTH_ITEMS)
                       {
                               String[] currItem = readItems.split(",");
                               if (loopBirth == currBirth)
                               {
                                       itemId = Integer.parseInt(currItem[0]);
                                       itemCount = Integer.parseInt(currItem[1]);
                                       break;
                               }
                               loopBirth++;
                       }
                      
                       // Rewards the player with an item.
                       rebirthItemReward(player, itemId, itemCount);
                      
                       // Check and see if its the player's first rebirth calling.
                       boolean firstBirth = currBirth == 0;
                      
                       // Player meets requirements and starts Rebirth process.
                       grantRebirth(player, (currBirth + 1), firstBirth);
               }
               else
                       super.onBypassFeedback(player, command);
       }
      
       @Override
       public void showChatWindow(Player player)
       {
               NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
               html.setFile("data/html/managers/rebirth.htm");
               html.replace("%objectId%", String.valueOf(getObjectId()));
               html.replace("%level%", + Config.REBIRTH_RETURN_TO_LEVEL);
              
               player.sendPacket(html);
    }
      
       /**
        * Physically rewards player and resets status to nothing.
        *
        * @param player the player
        * @param newBirthCount the new birth count
        * @param firstBirth the first birth
        */
       public void grantRebirth(Player player, int newBirthCount, boolean firstBirth)
       {
               try
               {
                       // Delevel.
                       player.removeExpAndSp(player.getExp() - Experience.LEVEL[Config.REBIRTH_RETURN_TO_LEVEL], 0);
                      
                       // Back to the first class.
                       player.setClassId(player.getClassId().getFirstClass().getId());
                      
                       // Send the Server->Client packet StatusUpdate with current HP, MP and CP to this L2PcInstance
                       player.broadcastStatusUpdate();
                      
                       // Broadcast informations from a user to himself and his knownlist.
                       player.broadcastUserInfo();
                      
                       // Remove the player's current skills.
                       for (L2Skill skill : player.getAllSkills())
                               player.removeSkill(skill);
                      
                       // Give all available skills to the player.
                       player.giveAvailableSkills();
                      
                       // Update L2PcInstance stats in the characters table of the database.
                       player.store();
                      
                       if (firstBirth)
                               // Stores the player's information in the DB.
                               storePlayerBirth(player);
                       else
                               // Updates the player's information in the DB.
                               updatePlayerBirth(player, newBirthCount);
                      
                       // Displays a congratulation window to the player.
                       NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
                       html.setFile("data/html/managers/rebirth-successfully.htm");
                       html.replace("%level%", + Config.REBIRTH_RETURN_TO_LEVEL);
                      
                       player.sendPacket(html);
               }
               catch (Exception e)
               {
                       e.printStackTrace();
               }
       }
      
       /**
        * Rewards the player with an item.
        *
        * @param player the player
        * @param itemId : Identifier of the item.
        * @param itemCount : Quantity of items to add.
        */
       public static void rebirthItemReward(Player player, int itemId, int itemCount)
       {
               // Incorrect amount.
               if (itemCount <= 0)
                       return;
              
               final ItemInstance item = player.getInventory().addItem("Quest", itemId, itemCount, player, player);
               if (item == null)
                       return;
              
               // Send message to the client.
               if (itemId == 57)
               {
                       SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S1_ADENA);
                       smsg.addItemNumber(itemCount);
                       player.sendPacket(smsg);
               }
               else
               {
                       if (itemCount > 1)
                       {
                               SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
                               smsg.addItemName(itemId);
                               smsg.addItemNumber(itemCount);
                               player.sendPacket(smsg);
                       }
                       else
                       {
                               SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
                               smsg.addItemName(itemId);
                               player.sendPacket(smsg);
                       }
               }
              
               // Send status update packet.
               StatusUpdate su = new StatusUpdate(player);
               su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
               player.sendPacket(su);
       }
      
       /**
        * Return the player's current Rebirth Level.
        *
        * @param player the player
        * @return the rebirth level
        */
       public static int getRebirthLevel(Player player)
       {
               int playerId = player.getObjectId();
               if (_rebirthInfo.get(playerId) == null)
                       loadRebirthInfo(player);
              
               return _rebirthInfo.get(playerId);
       }
      
       /**
        * Database caller to retrieve player's current Rebirth Level.
        *
        * @param player the player
        */
       public static void loadRebirthInfo(Player player)
       {
               int playerId = player.getObjectId(), rebirthCount = 0;
              
               try (Connection con = L2DatabaseFactory.getInstance().getConnection())
               {
                       ResultSet rset;
                       PreparedStatement statement = con.prepareStatement("SELECT * FROM `character_rebirths` WHERE playerId = ?");
                       statement.setInt(1, playerId);
                       rset = statement.executeQuery();
                      
                       while (rset.next())
                       {
                               rebirthCount = rset.getInt("rebirthCount");
                       }
                      
                       rset.close();
                       statement.close();
               }
               catch (Exception e)
               {
                       e.printStackTrace();
               }
               _rebirthInfo.put(playerId, rebirthCount);
       }
      
       /**
        * Stores the player's information in the DB.
        *
        * @param player the player
        */
       public static void storePlayerBirth(Player player)
       {
               try (Connection con = L2DatabaseFactory.getInstance().getConnection())
               {
                       @SuppressWarnings("resource")
                    PreparedStatement statement = con.prepareStatement("INSERT INTO `character_rebirths` (playerId,rebirthCount) VALUES (?,1)");
                       statement.setInt(1, player.getObjectId());
                       statement.execute();
                      
                       _rebirthInfo.put(player.getObjectId(), 1);
               }
               catch (Exception e)
               {
                       e.printStackTrace();
               }
       }
      
       /**
        * Updates the player's information in the DB.
        *
        * @param player the player
        * @param newRebirthCount the new rebirth count
        */
       public static void updatePlayerBirth(Player player, int newRebirthCount)
       {
               int playerId = player.getObjectId();
              
               try (Connection con = L2DatabaseFactory.getInstance().getConnection())
               {
                       @SuppressWarnings("resource")
                    PreparedStatement statement = con.prepareStatement("UPDATE `character_rebirths` SET rebirthCount = ? WHERE playerId = ?");
                       statement.setInt(1, newRebirthCount);
                       statement.setInt(2, playerId);
                       statement.execute();
                      
                       _rebirthInfo.put(playerId, newRebirthCount);
               }
               catch (Exception e)
               {
                       e.printStackTrace();
               }
       }
}

Edited by remigas

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • ElmoreLab Harbor - Eternal C1 x1: ✅ https://harbor.elmorelab.com ElmoreLab Harbor - Eternal C1 x1 - is an exclusive server of the Eternal C1 chronicles from the top project ElmoreLab Harbor.   A unique server of its kind, on which everyone will have maximum pleasure, such as oldschool players who dream of nostalgia and to feel the warmest and classic C1 chronicles, as well as experienced players who are tired of thousands unbalanced servers of late chronicles. Due to the professional corrections of the balance system and the HONEST gameplay system - on this server, EVERY player will feel like in their own, warm and cozy Harbor C1. Let's return to the origins of L2 - back to 2004 in C1! ❤️   ⭐ Server characteristics:   STRICTLY 1 window, NO BOXES Bans for RMT and bots/cheats No donations with benefits Unique and high-quality PTS-build from Master Toma Professional corrections and full class-balance Reworked economy and closed all abuses Improved animations and all aspects of the game Exclusive HD-client with high-quality textures Experienced administration and management Fixed all bugs, geodata, exploits and holes Maximum sociality due to the 1-box system Discovering, exploring and researching Big online International server Nostalgia and oldschool-feelings   Rates: x1 Server start: 14.02.2025   The server is at the final stages of development and preparation for release. Information on the server will be updated, soon the patchnotes and changes/edits will be posted. Don't miss the legendary and epic experience on the best server in the last 20 years! ❤️ Join our C1-forum with a lot of information about server and active discussions.   ⭐ Website: https://harbor.elmorelab.com   ✅ Forum: https://forum-harbor.elmorelab.com   💥 Telegram: https://t.me/l2harbor https://t.me/l2harbor_chat   ⚡ Discord: https://discord.gg/harborelmorelab
    • yeah ok, if you say what is fuctional 100% i can't say something different 😛  but if someone find hard to compile it or get vs and all that things i have here one more simple way here to put overlay in your own server or to change your window name with few money.
    • I've been using this for 2 years now with no issues from Discord. I don't use ogg.dll either. This one works with any l2.exe too; I don’t see any difference between them.
    • hmm.. ok i just see that, is different code first of all. My sources is totally different based in other way, with else libraries.  I have access to modify everything even to make the clock to stop show how many time users play in server. 1) so maybe keep some personal info more hide. 2) i dont use ogg.dll 3) i create it and give it ready + support to install it. Plus what is mine can working with what ever .exe you want not just l2 with same simple method. And i am sure if you try this source to compile it, after 3 hours discord will like shadowban your API too thats my source
  • Topics

×
×
  • Create New...