Advertisement
Guest User

Untitled

a guest
Feb 27th, 2011
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 25.31 KB | None | 0 0
  1. Index: C:/workspace/L2_GameServer/java/config/l2jmods.properties
  2. ===================================================================
  3. +
  4. +# ---------------------------------------------------------------------------
  5. +# Religion System By x.v3ndetta@yahoo.com
  6. +# ---------------------------------------------------------------------------
  7. +# Religion System is Something Really Unique. You Must Have Full Knowledge of What You Are Doing When Activating It.
  8. +# Religion System Work With TvT Events , CTF , DM , KOTH And Others.
  9. +
  10. +# Enable V3ndetta Religion System?
  11. +ReligionSystemEnable = False
  12. +
  13. +# Set The Religion Name of The First Religion.
  14. +FirstReligionName = Demons
  15. +
  16. +# Set The Religion Name of The Second Religion.
  17. +SecondReligionName = Angels
  18. +
  19. +# Set All The New Characters Heroes , On Their Creation?
  20. +NewCharSetHero = False
  21. +
  22. +# Set The Name Color of The First Religion
  23. +# Values Must Be In RGB
  24. +FirstReligionNameColor =
  25. +
  26. +# Set The Name Color of The Second Religion
  27. +# Values Must Be In RGB
  28. +SecondReligionNameColor =
  29. +
  30. +# Allow Reward for Each PvP?
  31. +AllowPvPReward = False
  32. +
  33. +# Set The Item You Want as a Reward
  34. +PvPRewardID = 57
  35. +
  36. +# Set The Amount of The Reward
  37. +PvPRewardAmount = 1
  38. +
  39.  
  40.  
  41. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/gameservermodel/L2Character.java
  42. ===================================================================
  43.  
  44.         if (!isTeleporting())
  45.         {
  46.             setIsPendingRevive(false);
  47. +           if ((this instanceof L2PcInstance) && (((L2PcInstance) this).isdemon() && Config.RELIGION_SYSTEM_ENABLE))
  48. +           {
  49. +           teleToLocation(73056, 142127, -3798);
  50. +           } else
  51. +           {
  52. +           if ((this instanceof L2PcInstance) && (((L2PcInstance) this).isangel() && Config.RELIGION_SYSTEM_ENABLE))
  53. +           {
  54. +               teleToLocation(72954, 143363, -3798);
  55. +           }
  56. +           }
  57.             setIsDead(false);
  58.             boolean restorefull = false;
  59.  
  60.        
  61. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  62. ===================================================================
  63.  
  64.         // Set Hero status if it applies
  65.         if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()))
  66.             activeChar.setHero(true);
  67.  
  68. +       if (Config.RELIGION_SYSTEM_NEW_CHAR_SET_HERO)
  69. +       {
  70. +       if(!activeChar.isHero())
  71. +           activeChar.setHero(true);
  72. +       }
  73. +      
  74.         setPledgeClass(activeChar);
  75.  
  76.         boolean showClanNotice = false;
  77. @@ -324,6 +336,21 @@
  78.             notifyPartner(activeChar,activeChar.getPartnerId());
  79.         }
  80.  
  81.         if (activeChar.isCursedWeaponEquipped())
  82.         {
  83.             CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
  84.            
  85.            
  86.  
  87. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  88. ===================================================================
  89.  
  90.     // Character Character SQL String Definitions:
  91.      private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  92. -   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=? WHERE charId=?";
  93. -    private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot FROM characters WHERE charId=?";
  94. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,demon=?,angel=? WHERE charId=?";
  95. +    private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,demon,angel FROM characters WHERE charId=?";
  96.  
  97.      // Character Teleport Bookmark:
  98.      private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
  99. @@ -524,6 +524,9 @@
  100.     private boolean _noble = false;
  101.     private boolean _hero = false;
  102.  
  103. +    private boolean _isdemon = false;
  104. +    private boolean _isangel = false;
  105. +    
  106.     /** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
  107.     private L2Npc _lastFolkNpc = null;
  108.  
  109. @@ -5469,6 +5472,27 @@
  110.             // sendPacket(msg);
  111.             return;
  112.         }
  113. +       if (Config.RELIGION_SYSTEM_ALLOW_REWARD_FOR_EACH_PVP && Config.RELIGION_SYSTEM_ENABLE)
  114. +       {
  115. +           if ((isangel() && targetPlayer.isangel()) || (isdemon() && targetPlayer.isdemon()))
  116. +           {
  117. +           sendPacket(ActionFailed.STATIC_PACKET);
  118. +           return;
  119. +           } else
  120. +           {
  121. +           int itemReward = Config.RELIGION_SYSTEM_PVP_ITEM_REWARD_AMOUNT;
  122. +           int idReward = Config.RELIGION_SYSTEM_PVP_ITEM_REWARD_ID;
  123. +           addItem("Loot", idReward, itemReward, this, true);
  124. +           sendMessage("You Won " + itemReward + " " + idReward + "  From Your Kill.");
  125. +           }
  126. +       }
  127. +       // pvp?
  128. +       if (checkIfPvP(target) || (isdemon() && targetPlayer.isangel()) || (isangel() && targetPlayer.isdemon()))
  129. +       {
  130. +           increasePvpKills();
  131. +           return;
  132. +       }
  133.  
  134.         // If in duel and you kill (only can kill l2summon), do nothing
  135.         if (isInDuel() && targetPlayer.isInDuel()) return;
  136. @@ -5558,6 +5582,11 @@
  137.       */
  138.      public void increasePkKillsAndKarma(int targLVL)
  139.      {
  140. +       if (Config.RELIGION_SYSTEM_ENABLE)
  141. +       {
  142. +           return;
  143. +       }
  144. +      
  145.          int baseKarma           = Config.KARMA_MIN_KARMA;
  146.          int newKarma            = baseKarma;
  147.          int karmaLimit          = Config.KARMA_MAX_KARMA;
  148. @@ -5629,11 +5658,19 @@
  149.  
  150.     public void updatePvPStatus()
  151.     {
  152. +  
  153. +       if (!isangel() || !isdemon())
  154. +       {
  155. +           return;
  156. +       }
  157. +      
  158.         if (isInsideZone(ZONE_PVP)) return;
  159.         setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME);
  160.  
  161.         if (getPvpFlag() == 0)
  162.             startPvPFlag();
  163. +      
  164. +      
  165.     }
  166.  
  167.     public void updatePvPStatus(L2Character target)
  168. @@ -5643,6 +5680,14 @@
  169.          if (player_target == null)
  170.             return;
  171.  
  172. +       if (target  instanceof L2PcInstance)
  173. +       {
  174. +           player_target = (L2PcInstance) target;
  175. +       }
  176. +       if (player_target.isangel() || player_target.isdemon())
  177. +       {
  178. +           return;
  179. +       }
  180.          if ((isInDuel() && player_target.getDuelId() == getDuelId())) return;
  181.          if ((!isInsideZone(ZONE_PVP) || !player_target.isInsideZone(ZONE_PVP)) && player_target.getKarma() == 0)
  182.          {
  183. @@ -5655,6 +5700,7 @@
  184.          }
  185.     }
  186.  
  187. +
  188.     /**
  189.      * Restore the specified % of experience this L2PcInstance has
  190.      * lost and sends a Server->Client StatusUpdate packet.<BR><BR>
  191. @@ -7018,6 +7064,8 @@
  192.                 player.setOnlineTime(rset.getLong("onlinetime"));
  193.                 player.setNewbie(rset.getInt("newbie"));
  194.                 player.setNoble(rset.getInt("nobless")==1);
  195. +               player.setdemon(rset.getInt("demon") == 1 ? true : false);
  196. +               player.setangel(rset.getInt("angel") == 1 ? true : false);
  197.  
  198.                 player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
  199.                 if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
  200. @@ -7450,7 +7498,9 @@
  201.             statement.setString(50, getName());
  202.             statement.setLong(51, getDeathPenaltyBuffLevel());
  203.             statement.setInt(52, getBookMarkSlot());
  204. -            statement.setInt(53, getObjectId());
  205. +           statement.setInt(53, isdemon() ? 1 : 0);
  206. +           statement.setInt(54, isangel() ? 1 : 0);
  207. +            statement.setInt(55, getObjectId());
  208.  
  209.             statement.execute();
  210.             statement.close();
  211. @@ -8254,6 +8304,16 @@
  212.     @Override
  213.     public boolean isAutoAttackable(L2Character attacker)
  214.     {
  215. +      
  216. +       if ((attacker instanceof L2PcInstance) && ((L2PcInstance) attacker).isdemon())
  217. +       {
  218. +           return true;
  219. +       }
  220. +       if ((attacker instanceof L2PcInstance) && ((L2PcInstance) attacker).isangel())
  221. +       {
  222. +           return true;
  223. +       }
  224. +      
  225.         // Check if the attacker isn't the L2PcInstance Pet
  226.         if (attacker == this || attacker == getPet())
  227.             return false;
  228. @@ -8651,7 +8711,7 @@
  229.          // Check if this is offensive magic skill
  230.          if (skill.isOffensive())
  231.         {
  232.             if ((isInsidePeaceZone(this, target)) && !getAccessLevel().allowPeaceAttack())
  233.             {
  234.                 // If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed
  235.                 sendPacket(new SystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
  236. @@ -9056,6 +9116,12 @@
  237.      */
  238.     public boolean checkPvpSkill(L2Object target, L2Skill skill, boolean srcIsSummon)
  239.     {
  240. +      
  241. +       if (isangel() || isdemon())
  242. +       {
  243. +           return true;
  244. +       }  
  245. +      
  246.         // check for PC->PC Pvp status
  247.         if (
  248.                 target != null &&                                                       // target not null and
  249. @@ -10010,6 +10076,27 @@
  250.         sendPacket(sl);  
  251.      }
  252.      
  253. +    public boolean isdemon()
  254. +    {
  255. +   return _isdemon;
  256. +    }
  257. +
  258. +    public boolean isangel()
  259. +    {
  260. +   return _isangel;
  261. +    }
  262. +
  263. +    public void setdemon(boolean value)
  264. +    {
  265. +   _isdemon = value;
  266. +    }
  267. +
  268. +    public void setangel(boolean value)
  269. +    {
  270. +   _isangel = value;
  271. +    }
  272. +
  273. +    
  274.      /**
  275.       * 1. Add the specified class ID as a subclass (up to the maximum number of <b>three</b>)
  276.       * for this character.<BR>
  277.      
  278.      
  279. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/model/L2World.java
  280. ===================================================================
  281.  
  282.     /** HashMap(String Player name, L2PcInstance) containing all the players in game */
  283.     private Map<String, L2PcInstance> _allPlayers;
  284.    
  285. +    private Map<String, L2PcInstance> _allkoofPlayers;
  286. +    private Map<String, L2PcInstance> _allnoobPlayers;
  287. +    
  288.     /** L2ObjectHashMap(L2Object) containing all visible objects */
  289.     private Map<Integer, L2Object> _allObjects;
  290.    
  291. @@ -79,6 +82,8 @@
  292.     {
  293.         //_allGms    = new FastMap<String, L2PcInstance>();
  294.         _allPlayers = new FastMap<String, L2PcInstance>().setShared(true);
  295. +       _allkoofPlayers = new FastMap<String, L2PcInstance>().setShared(true);
  296. +       _allnoobPlayers = new FastMap<String, L2PcInstance>().setShared(true);
  297.         _petsInstance = new FastMap<Integer, L2PetInstance>().setShared(true);
  298.         _allObjects = new FastMap<Integer, L2Object>().setShared(true);
  299.        
  300. @@ -224,6 +229,16 @@
  301.         return _allPlayers;
  302.     }
  303.    
  304. +    public Collection<L2PcInstance> getAllkoofPlayers()
  305. +    {
  306. +   return _allkoofPlayers.values();
  307. +    }
  308. +
  309. +    public Collection<L2PcInstance> getAllnoobPlayers()
  310. +    {
  311. +   return _allnoobPlayers.values();
  312. +    }
  313. +
  314.     /**
  315.      * Return how many players are online.<BR><BR>
  316.      *
  317. @@ -234,6 +249,16 @@
  318.         return _allPlayers.size();
  319.     }
  320.    
  321. +    public int getAllkoofPlayersCount()
  322. +    {
  323. +   return _allkoofPlayers.size();
  324. +    }
  325. +
  326. +    public int getAllnoobPlayersCount()
  327. +    {
  328. +   return _allnoobPlayers.size();
  329. +    }
  330. +
  331.     /**
  332.      * Return the player instance corresponding to the given name.<BR><BR>
  333.      *
  334. @@ -335,6 +360,14 @@
  335.                     tmp.closeNetConnection();
  336.                     return;
  337.                 }
  338. +               if (((L2PcInstance) object).isdemon())
  339. +               {
  340. +               _allkoofPlayers.put(player.getName().toLowerCase(), player);
  341. +               }
  342. +               else if (((L2PcInstance) object).isangel())
  343. +               {
  344. +               _allnoobPlayers.put(player.getName().toLowerCase(), player);
  345. +               }
  346.                 _allPlayers.put(player.getName().toLowerCase(), player);
  347.             }
  348.         }
  349.        
  350.  
  351. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/GameServer.java
  352. ===================================================================
  353.  
  354.         _log.config("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);
  355.         long serverLoadEnd = System.currentTimeMillis();
  356.         _log.info("Server Loaded in " + ((serverLoadEnd - serverLoadStart) / 1000) + " seconds");
  357. +      
  358.     }
  359.    
  360.     public static void main(String[] args) throws Exception
  361. @@ -557,5 +558,18 @@
  362.         {
  363.             _log.info("Telnet server is currently disabled.");
  364.         }
  365. +       if (Config.RELIGION_SYSTEM_ENABLE)
  366. +       {
  367. +           System.out.println("####################################");
  368. +           System.out.println("##  Religion System is Activated. ##");
  369. +           System.out.println("####################################");
  370. +       }
  371. +       else
  372. +       {
  373. +           System.out.println("###################################");
  374. +           System.out.println("##  Religion System is Disabled. ##");
  375. +           System.out.println("###################################");
  376. +       }
  377. +  
  378.     }
  379.  }
  380.  
  381.  
  382. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/Config.java
  383. ===================================================================
  384.  
  385.     public static boolean OFFLINE_SET_NAME_COLOR;
  386.     public static int OFFLINE_NAME_COLOR;
  387.     public static boolean L2JMOD_ENABLE_MANA_POTIONS_SUPPORT;
  388. +   public static boolean RELIGION_SYSTEM_ENABLE;
  389. +   public static String RELIGION_SYSTEM_FIRST_NAME;
  390. +   public static String RELIGION_SYSTEM_SECOND_NAME;
  391. +    public static boolean RELIGION_SYSTEM_NEW_CHAR_SET_HERO;
  392. +    public static int RELIGION_SYSTEM_FIRST_NAME_COLOR;
  393. +    public static int RELIGION_SYSTEM_SECOND_NAME_COLOR;
  394. +    public static boolean RELIGION_SYSTEM_ALLOW_REWARD_FOR_EACH_PVP;
  395. +    public static int RELIGION_SYSTEM_PVP_ITEM_REWARD_ID;
  396. +    public static int RELIGION_SYSTEM_PVP_ITEM_REWARD_AMOUNT;
  397.  
  398. -
  399.     //--------------------------------------------------
  400.     // NPC Settings
  401.     //--------------------------------------------------
  402. @@ -1932,6 +1961,36 @@
  403.                     OFFLINE_NAME_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("OfflineNameColor", "808080"));
  404.  
  405.                     L2JMOD_ENABLE_MANA_POTIONS_SUPPORT = Boolean.parseBoolean(L2JModSettings.getProperty("EnableManaPotionSupport", "false"));
  406. +                   RELIGION_SYSTEM_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("ReligionSystemEnable", "False"));
  407. +                   RELIGION_SYSTEM_FIRST_NAME = L2JModSettings.getProperty("FirstReligionName", "Demons");
  408. +                   RELIGION_SYSTEM_SECOND_NAME = L2JModSettings.getProperty("SecondReligionName", "Angels");
  409. +                   RELIGION_SYSTEM_NEW_CHAR_SET_HERO = Boolean.parseBoolean(L2JModSettings.getProperty("NewCharSetHero", "False"));
  410. +                   RELIGION_SYSTEM_FIRST_NAME_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("FirstReligionNameColor", ""));
  411. +                   RELIGION_SYSTEM_SECOND_NAME_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("SecondReligionNameColor", ""));
  412. +                   RELIGION_SYSTEM_ALLOW_REWARD_FOR_EACH_PVP = Boolean.parseBoolean(L2JModSettings.getProperty("AllowPvPReward", "False"));
  413. +                   RELIGION_SYSTEM_PVP_ITEM_REWARD_ID = Integer.parseInt(L2JModSettings.getProperty("PvPRewardID", "57"));
  414. +                   RELIGION_SYSTEM_PVP_ITEM_REWARD_AMOUNT = Integer.parseInt(L2JModSettings.getProperty("PvPRewardAmount", "1"));
  415.  
  416.                 }
  417.                 catch (Exception e)
  418.                 {
  419.  
  420.                
  421. Index: C:/workspace/L2_GameServer/java/net/sf/l2j/model/actor/instance/L2ReligionInstance.java
  422. ===================================================================            
  423.  
  424.  
  425. /*
  426.  * This program is free software: you can redistribute it and/or modify it under
  427.  * the terms of the GNU General Public License as published by the Free Software
  428.  * Foundation, either version 3 of the License, or (at your option) any later
  429.  * version.
  430.  *
  431.  * This program is distributed in the hope that it will be useful, but WITHOUT
  432.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  433.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  434.  * details.
  435.  *
  436.  * You should have received a copy of the GNU General Public License along with
  437.  * this program. If not, see <http://www.gnu.org/licenses/>.
  438.  */
  439. package com.l2scoria.gameserver.model.actor.instance;
  440.  
  441. import java.sql.Connection;
  442. import java.sql.PreparedStatement;
  443. import java.sql.ResultSet;
  444. import java.util.StringTokenizer;
  445. import java.util.logging.Logger;
  446.  
  447. import com.l2scoria.Config;
  448. import com.l2scoria.util.database.L2DatabaseFactory;
  449. import com.l2scoria.gameserver.ai.CtrlIntention;
  450. import com.l2scoria.gameserver.model.L2World;
  451. import com.l2scoria.gameserver.network.serverpackets.ActionFailed;
  452. import com.l2scoria.gameserver.network.serverpackets.MyTargetSelected;
  453. import com.l2scoria.gameserver.network.serverpackets.NpcHtmlMessage;
  454. import com.l2scoria.gameserver.network.serverpackets.SocialAction;
  455. import com.l2scoria.gameserver.network.serverpackets.ValidateLocation;
  456. import com.l2scoria.gameserver.templates.L2NpcTemplate;
  457. import com.l2scoria.util.random.Rnd;
  458.  
  459. public class L2ReligionInstance extends L2FolkInstance
  460. {
  461.     public L2ReligionInstance(int objectId, L2NpcTemplate template)
  462.     {
  463.         super(objectId, template);
  464.     }
  465.  
  466.     private final static Logger _log = Logger.getLogger(L2ReligionInstance.class.getName());
  467.  
  468.     @Override
  469.     public void onBypassFeedback(L2PcInstance player, String command)
  470.     {
  471.         player.sendPacket(new ActionFailed());
  472.         StringTokenizer st = new StringTokenizer(command, " ");
  473.         String actualCommand = st.nextToken();
  474.         String val = "";
  475.         if (st.countTokens() >= 1)
  476.         {
  477.             val = st.nextToken();
  478.         }
  479.         else if (actualCommand.equalsIgnoreCase("levelup"))
  480.         {
  481.             setTarget(player);
  482.             int lvl = player.getLevel();
  483.             if (val.equalsIgnoreCase("1"))
  484.             {
  485.                 long addexp = 0;
  486.                 addexp = player.getStat().getExpForLevel(lvl + 1) - player.getStat().getExp();
  487.                 player.getStat().addExp(addexp);
  488.                 player.broadcastKarma();
  489.                 player.sendMessage("level Up was Successfull.");
  490.             } else
  491.             {
  492.                 NpcHtmlMessage html = new NpcHtmlMessage(1);
  493.                 html.setFile("data/html/mods/Faction/levelup.htm");
  494.                 html.replace("%lvl%", String.valueOf(player.getLevel()));
  495.                 sendHtmlMessage(player, html);
  496.             }    
  497.         }  else if (actualCommand.equalsIgnoreCase("setangel"))
  498.         {
  499.             setTarget(player);
  500.             if (player.isangel())
  501.             {
  502.                 player.sendMessage("You Are Allready a " + Config.RELIGION_SYSTEM_SECOND_NAME + " religion ");
  503.                 player.sendPacket(new ActionFailed());
  504.             } else
  505.             {
  506.                 if (player.isdemon())
  507.                 {
  508.                     player.sendMessage("You Can't Change Religion.");
  509.                     player.sendPacket(new ActionFailed());
  510.                 } else
  511.                 {
  512.                     {
  513.                         player.setangel(true);
  514.                         Connection connection = null;
  515.                         try
  516.                         {
  517.                             connection = L2DatabaseFactory.getInstance().getConnection();
  518.                             PreparedStatement statement = connection.prepareStatement("SELECT obj_id FROM characters where char_name=?");
  519.                             statement.setString(1, player.getName());
  520.                             ResultSet rset = statement.executeQuery();
  521.                             int objId = 0;
  522.                             if (rset.next())
  523.                             {
  524.                                 objId = rset.getInt(1);
  525.                             }
  526.                             rset.close();
  527.                             statement.close();
  528.                             if (objId == 0)
  529.                             {
  530.                                 connection.close();
  531.                                 return;
  532.                             }
  533.                             statement = connection.prepareStatement("UPDATE characters SET angel=1 WHERE obj_id=?");
  534.                             statement.setInt(1, objId);
  535.                             statement.execute();
  536.                             statement.close();
  537.                             connection.close();
  538.                         } catch (Exception e)
  539.                         {
  540.                             _log.info("could not set angel status of char:");
  541.                         } finally
  542.                         {
  543.                             try
  544.                             {
  545.                                 connection.close();
  546.                             } catch (Exception e)
  547.                             {
  548.                             }
  549.                         }
  550.                         System.out.println("##Religion Engine## : player " + player.getName() + " Has Choose " + Config.RELIGION_SYSTEM_SECOND_NAME + " Faction");
  551.                         if (player.isangel() == true)
  552.                         {
  553.                             player.broadcastUserInfo();
  554.                             player.sendMessage("You Are fighiting Now for " + Config.RELIGION_SYSTEM_SECOND_NAME + " Faction ");
  555.                             player.getAppearance().setNameColor(Config.RELIGION_SYSTEM_SECOND_NAME_COLOR);
  556.                             player.setTitle(Config.RELIGION_SYSTEM_SECOND_NAME);
  557.                             player.teleToLocation(-83995, 243373, -3755);
  558.                         }
  559.                     }
  560.                 }
  561.             }          
  562.         } else if (actualCommand.equalsIgnoreCase("setdemon"))
  563.         {
  564.             setTarget(player);
  565.             if (player.isdemon())
  566.             {
  567.                 player.sendMessage("You Are Allready a " + Config.RELIGION_SYSTEM_SECOND_NAME + " religion ");
  568.                 player.sendPacket(new ActionFailed());
  569.             } else
  570.             {
  571.                 if (player.isangel())
  572.                 {
  573.                     player.sendMessage("You Can't Change Religion.");
  574.                     player.sendPacket(new ActionFailed());
  575.                 } else
  576.                 {
  577.                     {
  578.                         player.setdemon(true);
  579.                         Connection connection = null;
  580.                         try
  581.                         {
  582.                             connection = L2DatabaseFactory.getInstance().getConnection();
  583.                             PreparedStatement statement = connection.prepareStatement("SELECT obj_id FROM characters where char_name=?");
  584.                             statement.setString(1, player.getName());
  585.                             ResultSet rset = statement.executeQuery();
  586.                             int objId = 0;
  587.                             if (rset.next())
  588.                             {
  589.                                 objId = rset.getInt(1);
  590.                             }
  591.                             rset.close();
  592.                             statement.close();
  593.                             if (objId == 0)
  594.                             {
  595.                                 connection.close();
  596.                                 return;
  597.                             }
  598.                             statement = connection.prepareStatement("UPDATE characters SET demon=1 WHERE obj_id=?");
  599.                             statement.setInt(1, objId);
  600.                             statement.execute();
  601.                             statement.close();
  602.                             connection.close();
  603.                         } catch (Exception e)
  604.                         {
  605.                             _log.info("could not set demon status of char:");
  606.                         } finally
  607.                         {
  608.                             try
  609.                             {
  610.                                 connection.close();
  611.                             } catch (Exception e)
  612.                             {
  613.                             }
  614.                         }
  615.                         System.out.println("##Religion Engine## : player " + player.getName() + " Has Choose " + Config.RELIGION_SYSTEM_FIRST_NAME + " Faction");
  616.                         if (player.isangel() == true)
  617.                         {
  618.                             player.broadcastUserInfo();
  619.                             player.sendMessage("You Are fighiting Now for " + Config.RELIGION_SYSTEM_FIRST_NAME + " Faction ");
  620.                             player.getAppearance().setNameColor(Config.RELIGION_SYSTEM_FIRST_NAME_COLOR);
  621.                             player.setTitle(Config.RELIGION_SYSTEM_FIRST_NAME);
  622.                             player.teleToLocation(-83995, 243373, -3755);
  623.                         }
  624.                     }
  625.                 }
  626.             }          
  627.         }
  628.        
  629.         else
  630.         {
  631.             super.onBypassFeedback(player, command);
  632.         }
  633.     }
  634.  
  635.     @Override
  636.     public void onAction(L2PcInstance player)
  637.     {
  638.         if (this != player.getTarget())
  639.         {
  640.             player.setTarget(this);
  641.             player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  642.             player.sendPacket(new ValidateLocation(this));
  643.         } else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
  644.         {
  645.             SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));
  646.             broadcastPacket(sa);
  647.             player.setLastFolkNPC(this);
  648.             showMessageWindow(player);
  649.             player.sendPacket(new ActionFailed());
  650.         } else
  651.         {
  652.             player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  653.             player.sendPacket(new ActionFailed());
  654.         }
  655.     }
  656.  
  657.     private void showMessageWindow(L2PcInstance player)
  658.     {
  659.         NpcHtmlMessage html = new NpcHtmlMessage(1);
  660.         html.setFile("data/html/mods/Religion/religion.htm");
  661.         html.replace("%objectId%", String.valueOf(getObjectId()));
  662.         html.replace("%npcname%", getName());
  663.         player.sendPacket(html);
  664.     }
  665.  
  666.     private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html)
  667.     {
  668.         html.replace("%objectId%", String.valueOf(getObjectId()));
  669.         html.replace("%npcname%", getName());
  670.         html.replace("%npcId%", String.valueOf(getNpcId()));
  671.         player.sendPacket(html);
  672.     }
  673. }
  674.  
  675.  
  676.  
  677. Index: C:/workspace/L2_DataPatc/data/mods/Religion/religion.htm
  678. ===================================================================            
  679.  
  680. <html><title>Religion Manager</title>
  681. <body>
  682.  
  683. <center>
  684.  
  685. <font color="LEVEL">Choose Your Religion</font><br>
  686. <br>
  687.  
  688. <a action="bypass -h npc_%objectId%_setdemon">Join The Demons Faction</a><br>
  689. <br>
  690. <a action="bypass -h npc_%objectId%_setangel">Join The Angels Faction</a><br>
  691. <br>
  692. <br>
  693.  
  694. </center>
  695.  
  696. </body>
  697.  
  698. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement