Advertisement
dymek84

L2Pcinstance diff 1 pvppoints + party

Aug 3rd, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 15.65 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 5550)
  4. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  5. @@ -287,8 +287,8 @@
  6.    
  7.     // Character Character SQL String Definitions:
  8.     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,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createTime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  9. -   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=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=? WHERE charId=?";
  10. -   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, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language FROM characters WHERE charId=?";
  11. +   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=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,pvpPoints=?,rank=? WHERE charId=?";
  12. +   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, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language,pvpPoints,rank FROM characters WHERE charId=?";
  13.    
  14.     // Character Teleport Bookmark:
  15.     private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
  16. @@ -413,6 +413,10 @@
  17.     /** The PK counter of the L2PcInstance (= Number of non PvP Flagged player killed) */
  18.     private int _pkKills;
  19.    
  20. +   private int _pvpPoints;
  21. +  
  22. +   private int _rank;
  23. +  
  24.     /** The PvP Flag state of the L2PcInstance (0=White, 1=Purple) */
  25.     private byte _pvpFlag;
  26.    
  27. @@ -4343,7 +4347,67 @@
  28.             DuelManager.getInstance().broadcastToOppositTeam(this, update);
  29.         }
  30.     }
  31. -  
  32. +   public void updateRank()
  33. +   {
  34. +       if (Config.PVP_RANK_SYSTEM_ENABLED)
  35. +       {
  36. +           //Check if the character has GM access
  37. +           if (isGM())
  38. +               return;
  39. +           {
  40. +               if ((getPvpPoints() >= (Config.PVP_LVL1)) && (getPvpPoints() <= (Config.PVP_LVL2)))
  41. +               {
  42. +                   setRank(1);        
  43. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK1);
  44. +               }
  45. +               else if ((getPvpPoints() >= (Config.PVP_LVL2)) && (getPvpPoints() <= (Config.PVP_LVL3)))
  46. +               {
  47. +                   setRank(2);
  48. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK2);
  49. +               }
  50. +               else if ((getPvpPoints() >= (Config.PVP_LVL3)) && (getPvpPoints() <= (Config.PVP_LVL4)))
  51. +               {
  52. +                   setRank(3);
  53. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK3);
  54. +               }
  55. +               else if ((getPvpPoints() >= (Config.PVP_LVL4)) && (getPvpPoints() <= (Config.PVP_LVL5)))
  56. +               {
  57. +                   setRank(4);
  58. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK4);
  59. +               }
  60. +               else if ((getPvpPoints() >= (Config.PVP_LVL5)) && (getPvpPoints() <= (Config.PVP_LVL6)))
  61. +               {
  62. +                   setRank(5);
  63. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK5);
  64. +               }
  65. +               else if ((getPvpPoints() >= (Config.PVP_LVL6)) && (getPvpPoints() <= (Config.PVP_LVL7)))
  66. +               {
  67. +                   setRank(6);
  68. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK6);
  69. +               }
  70. +               else if ((getPvpPoints() >= (Config.PVP_LVL7)) && (getPvpPoints() <= (Config.PVP_LVL8)))
  71. +               {
  72. +                   setRank(7);
  73. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK7);
  74. +               }
  75. +               else if ((getPvpPoints() >= (Config.PVP_LVL8)) && (getPvpPoints() <= (Config.PVP_LVL9)))
  76. +               {
  77. +                   setRank(8);
  78. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK8);
  79. +               }
  80. +               else if ((getPvpPoints() >= (Config.PVP_LVL9)) && (getPvpPoints() <= (Config.PVP_LVL10)))
  81. +               {
  82. +                   setRank(9);
  83. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK9);
  84. +               }
  85. +               else if (getPvpPoints() >= (Config.PVP_LVL10))
  86. +               {
  87. +                   setRank(10);
  88. +                   getAppearance().setNameColor(Config.NAME_COLOR_FOR_RANK10);
  89. +               }
  90. +           }
  91. +       }
  92. +       }
  93.     /**
  94.      * Send a Server->Client packet UserInfo to this L2PcInstance and CharInfo to all L2PcInstance in its _KnownPlayers.<BR><BR>
  95.      *
  96. @@ -5337,6 +5401,54 @@
  97.        
  98.         if (killer != null)
  99.         {
  100. +           if (killer instanceof L2PcInstance && getPvpFlag() > 0)
  101. +           {
  102. +               L2Party party = killer.getParty();
  103. +               L2PcInstance kill = (L2PcInstance) killer;
  104. +               int pointsToAdd;
  105. +               if (party == null)
  106. +               {
  107. +                   pointsToAdd = (int) (_fame*0.05);
  108. +               }
  109. +               else
  110. +               {
  111. +                   pointsToAdd = (int) (_fame*0.05/party.getMemberCount());
  112. +               }
  113. +               int pointsToRemove = _fame - pointsToAdd < 0 ? 0 : _fame - pointsToAdd;
  114. +               kill.setFame(kill.getFame() + pointsToAdd);
  115. +               kill.setSp(kill.getSp() + pointsToAdd);
  116. +               kill.setPvpPoints(kill.getPvpPoints() + pointsToAdd);
  117. +               setFame(pointsToRemove);
  118. +               killer.sendMessage("You have earned " + pointsToAdd + " Fame Points from " + getName() + "");
  119. +               killer.broadcastPacket(new MagicSkillUse(killer, 23021, 1, 0, 0));
  120. +               broadcastUserInfo();
  121. +               {
  122. +                   if(killer instanceof L2PcInstance && getPvpFlag() > 0)
  123. +                   {
  124. +                       if (party != null)
  125. +                       {
  126. +                           for(L2PcInstance PartyMember : party.getPartyMembers())
  127. +                           {
  128. +                               if(PartyMember.isInsideRadius(this, 1600, true, false) && PartyMember != killer)
  129. +                               {
  130. +                                   int numberToAdd = (int) (_fame*0.05/party.getMemberCount());
  131. +                                   PartyMember.setFame(PartyMember.getFame() + numberToAdd);
  132. +                                   PartyMember.setSp(PartyMember.getSp() + numberToAdd);
  133. +                                   PartyMember.setPvpPoints(kill.getPvpPoints() + numberToAdd);
  134. +                                   int pointsToRemove1 = _fame - numberToAdd < 0 ? 0 : _fame - numberToAdd;
  135. +                                   setFame(pointsToRemove1);
  136. +                                   PartyMember.setPvpKills(PartyMember.getPvpKills() + 1);
  137. +                                   PartyMember.sendMessage("You have earned " + numberToAdd + " Fame Points from " + getName() + "");
  138. +                                   PartyMember.broadcastPacket(new MagicSkillUse(PartyMember, 23021, 1, 0, 0));
  139. +                                   broadcastUserInfo();
  140. +                               }
  141. +                           }
  142. +                       }
  143. +                   }
  144. +               }
  145. +           }
  146. +
  147. +           broadcastUserInfo();
  148.             L2PcInstance pk = killer.getActingPlayer();
  149.            
  150.             TvTEvent.onKill(killer, this);
  151. @@ -5683,7 +5795,8 @@
  152.         {
  153.             // Add karma to attacker and increase its PK counter
  154.             setPvpKills(getPvpKills() + 1);
  155. -          
  156. +           updateRank();
  157. +           broadcastUserInfo();
  158.             // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  159.             sendPacket(new UserInfo(this));
  160.             sendPacket(new ExBrExtraUserInfo(this));
  161. @@ -7027,6 +7140,8 @@
  162.             statement.setLong(36, 0);
  163.             statement.setLong(37,getCreateTime());
  164.            
  165. +          
  166. +          
  167.             statement.executeUpdate();
  168.             statement.close();
  169.         }
  170. @@ -7224,6 +7339,10 @@
  171.                 // Language
  172.                 player.setLang(rset.getString("language"));
  173.                
  174. +               player.setPvpPoints(rset.getInt("pvpPoints"));
  175. +              
  176. +               player.setRank(rset.getInt("rank"));
  177. +              
  178.                 // Retrieve the name and ID of the other characters assigned to this account.
  179.                 PreparedStatement stmt = con.prepareStatement("SELECT charId, char_name FROM characters WHERE account_name=? AND charId<>?");
  180.                 stmt.setString(1, player._accountName);
  181. @@ -7289,6 +7408,8 @@
  182.            
  183.             if (Config.STORE_UI_SETTINGS)
  184.                 player.restoreUISettings();
  185. +          
  186. +           player.updateRank();
  187.         }
  188.         catch (Exception e)
  189.         {
  190. @@ -7665,7 +7786,9 @@
  191.             statement.setInt(50, getBookMarkSlot());
  192.             statement.setInt(51, getVitalityPoints());
  193.             statement.setString(52, getLang());
  194. -           statement.setInt(53, getObjectId());
  195. +           statement.setInt(53, getPvpPoints());
  196. +           statement.setInt(54, getRank());
  197. +           statement.setInt(55, getObjectId());
  198.            
  199.             statement.execute();
  200.             statement.close();
  201. @@ -14475,7 +14598,25 @@
  202.             L2DatabaseFactory.close(con);
  203.         }
  204.     }
  205. +   public void setPvpPoints(int points)
  206. +   {
  207. +       _pvpPoints = points;
  208. +   }
  209.    
  210. +   public int getPvpPoints()
  211. +   {
  212. +       return _pvpPoints;
  213. +   }
  214. +   public void setRank(int rank)
  215. +   {
  216. +       _rank = rank;
  217. +   }
  218. +  
  219. +   public int getRank()
  220. +   {
  221. +       return _rank;
  222. +   }
  223. +  
  224.     public double getCollisionRadius()
  225.     {
  226.         if (getAppearance().getSex())
  227. Index: java/com/l2jserver/gameserver/network/clientpackets/Action.java
  228. ===================================================================
  229. --- java/com/l2jserver/gameserver/network/clientpackets/Action.java (revision 5550)
  230. +++ java/com/l2jserver/gameserver/network/clientpackets/Action.java (working copy)
  231. @@ -122,7 +122,7 @@
  232.                     obj.onAction(activeChar);
  233.                     break;
  234.                 case 1:
  235. -                   if (!activeChar.isGM() && !((obj instanceof L2Npc) && Config.ALT_GAME_VIEWNPC))
  236. +                   if (!activeChar.isGM() && !(obj instanceof L2PcInstance)&& !((obj instanceof L2Npc) && Config.ALT_GAME_VIEWNPC))
  237.                         obj.onAction(activeChar, false);
  238.                     else
  239.                         obj.onActionShift(activeChar);
  240. Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
  241. ===================================================================
  242. --- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 5550)
  243. +++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)
  244. @@ -328,6 +328,8 @@
  245.         }
  246.         activeChar.sendPacket(new QuestList());
  247.        
  248. +        if (activeChar.getPvpPoints()>=(Config.PVP_LVL1) && (Config.PVP_RANK_SYSTEM_ENABLED)) activeChar.updateRank();
  249. +      
  250.         if (Config.PLAYER_SPAWN_PROTECTION > 0)
  251.             activeChar.setProtection(true);
  252.        
  253. Index: java/com/l2jserver/Config.java
  254. ===================================================================
  255. --- java/com/l2jserver/Config.java  (revision 5550)
  256. +++ java/com/l2jserver/Config.java  (working copy)
  257. @@ -725,7 +725,27 @@
  258.     public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
  259.     public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
  260.     public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
  261. -  
  262. +   public static boolean           PVP_RANK_SYSTEM_ENABLED;
  263. +   public static int                       PVP_LVL1;
  264. +   public static int                       PVP_LVL2;
  265. +   public static int                       PVP_LVL3;
  266. +   public static int                       PVP_LVL4;
  267. +   public static int                       PVP_LVL5;
  268. +   public static int                       PVP_LVL6;
  269. +   public static int                       PVP_LVL7;
  270. +   public static int                       PVP_LVL8;
  271. +   public static int                       PVP_LVL9;
  272. +   public static int                       PVP_LVL10;
  273. +   public static int                       NAME_COLOR_FOR_RANK1;
  274. +   public static int                       NAME_COLOR_FOR_RANK2;
  275. +   public static int                       NAME_COLOR_FOR_RANK3;
  276. +   public static int                       NAME_COLOR_FOR_RANK4;
  277. +   public static int                       NAME_COLOR_FOR_RANK5;
  278. +   public static int                       NAME_COLOR_FOR_RANK6;
  279. +   public static int                       NAME_COLOR_FOR_RANK7;
  280. +   public static int                       NAME_COLOR_FOR_RANK8;
  281. +   public static int                       NAME_COLOR_FOR_RANK9;
  282. +   public static int                       NAME_COLOR_FOR_RANK10;
  283.     //--------------------------------------------------
  284.     // NPC Settings
  285.     //--------------------------------------------------
  286. @@ -2421,7 +2441,27 @@
  287.                             }
  288.                         }
  289.                     }
  290. -                  
  291. +                   PVP_RANK_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("EnableRankSystem", "true"));
  292. +                   PVP_LVL1 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl1", "25000"));
  293. +                   PVP_LVL2 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl2", "50000"));
  294. +                   PVP_LVL3 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl3", "75000"));
  295. +                   PVP_LVL4 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl4", "100000"));
  296. +                   PVP_LVL5 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl5", "150000"));
  297. +                   PVP_LVL6 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl6", "200000"));
  298. +                   PVP_LVL7 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl7", "300000"));
  299. +                   PVP_LVL8 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl8", "400000"));
  300. +                   PVP_LVL9 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl9", "500000"));
  301. +                   PVP_LVL10 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl10", "700000"));
  302. +                   NAME_COLOR_FOR_RANK1 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank1", "00FF00"));
  303. +                   NAME_COLOR_FOR_RANK2 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank2", "00FF00"));
  304. +                   NAME_COLOR_FOR_RANK3 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank3", "00FF00"));
  305. +                   NAME_COLOR_FOR_RANK4 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank4", "00FF00"));
  306. +                   NAME_COLOR_FOR_RANK5 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank5", "00FF00"));
  307. +                   NAME_COLOR_FOR_RANK6 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank6", "00FF00"));
  308. +                   NAME_COLOR_FOR_RANK7 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank7", "00FF00"));
  309. +                   NAME_COLOR_FOR_RANK8 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank8", "00FF00"));
  310. +                   NAME_COLOR_FOR_RANK9 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank9", "00FF00"));
  311. +                   NAME_COLOR_FOR_RANK10 = Integer.decode("0x" + L2JModSettings.getProperty("ColorForRank10", "00FF00"));
  312.                     BANKING_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("BankingEnabled", "false"));
  313.                     BANKING_SYSTEM_GOLDBARS = Integer.parseInt(L2JModSettings.getProperty("BankingGoldbarCount", "1"));
  314.                     BANKING_SYSTEM_ADENA = Integer.parseInt(L2JModSettings.getProperty("BankingAdenaCount", "500000000"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement