- Timestamp:
- Jan 16, 2012 7:56:19 AM (4 months ago)
- Location:
- trunk/L2J_DataPack
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
dist/game/data/scripts/handlers/bypasshandlers/Festival.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/L2J_DataPack
- Property svn:mergeinfo changed
/branches/unstable/L2J_DataPack_BETA merged: 8407-8426,8428-8480,8482-8491,8493-8588,8590-8629
- Property svn:mergeinfo changed
-
trunk/L2J_DataPack/dist/game/data/scripts/handlers/bypasshandlers/Festival.java
r8501 r8630 23 23 import com.l2jserver.gameserver.SevenSignsFestival; 24 24 import com.l2jserver.gameserver.handler.IBypassHandler; 25 import com.l2jserver.gameserver.model.L2ItemInstance;26 25 import com.l2jserver.gameserver.model.L2Party; 27 26 import com.l2jserver.gameserver.model.L2Party.messageType; 27 import com.l2jserver.gameserver.model.StatsSet; 28 28 import com.l2jserver.gameserver.model.actor.L2Character; 29 29 import com.l2jserver.gameserver.model.actor.instance.L2FestivalGuideInstance; 30 30 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; 31 import com.l2jserver.gameserver.model.item.instance.L2ItemInstance; 31 32 import com.l2jserver.gameserver.network.SystemMessageId; 32 33 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; 33 34 import com.l2jserver.gameserver.network.serverpackets.SystemMessage; 34 import com.l2jserver.gameserver.templates.StatsSet;35 35 import com.l2jserver.util.StringUtil; 36 36 … … 62 62 return true; 63 63 } 64 else 64 65 final L2Party party; 66 val = Integer.parseInt(command.substring(9, 10)); 67 switch (val) 65 68 { 66 final L2Party party; 67 val = Integer.parseInt(command.substring(9, 10)); 68 switch (val) 69 { 70 case 1: // Become a Participant 71 // Check if the festival period is active, if not then don't allow registration. 72 if (SevenSigns.getInstance().isSealValidationPeriod()) 69 case 1: // Become a Participant 70 // Check if the festival period is active, if not then don't allow registration. 71 if (SevenSigns.getInstance().isSealValidationPeriod()) 72 { 73 npc.showChatWindow(activeChar, 2, "a", false); 74 return true; 75 } 76 77 // Check if a festival is in progress, then don't allow registration yet. 78 if (SevenSignsFestival.getInstance().isFestivalInitialized()) 79 { 80 activeChar.sendMessage("You cannot sign up while a festival is in progress."); 81 return true; 82 } 83 84 // Check if the player is in a formed party already. 85 if (!activeChar.isInParty()) 86 { 87 npc.showChatWindow(activeChar, 2, "b", false); 88 return true; 89 } 90 91 party = activeChar.getParty(); 92 93 // Check if the player is the party leader. 94 if (!party.isLeader(activeChar)) 95 { 96 npc.showChatWindow(activeChar, 2, "c", false); 97 return true; 98 } 99 100 // Check to see if the party has at least 5 members. 101 if (party.getMemberCount() < Config.ALT_FESTIVAL_MIN_PLAYER) 102 { 103 npc.showChatWindow(activeChar, 2, "b", false); 104 return true; 105 } 106 107 // Check if all the party members are in the required level range. 108 if (party.getLevel() > SevenSignsFestival.getMaxLevelForFestival(npc.getFestivalType())) 109 { 110 npc.showChatWindow(activeChar, 2, "d", false); 111 return true; 112 } 113 114 // Check to see if the player has already signed up 115 if (activeChar.isFestivalParticipant()) 116 { 117 SevenSignsFestival.getInstance().setParticipants(npc.getFestivalOracle(), npc.getFestivalType(), party); 118 npc.showChatWindow(activeChar, 2, "f", false); 119 return true; 120 } 121 122 npc.showChatWindow(activeChar, 1, null, false); 123 break; 124 case 2: // Seal Stones 125 final int stoneType = Integer.parseInt(command.substring(11)); 126 final int stoneCount = npc.getStoneCount(stoneType); 127 if (stoneCount <= 0) 128 { 129 return false; 130 } 131 132 if (!activeChar.destroyItemByItemId("SevenSigns", stoneType, stoneCount, npc, true)) 133 { 134 return false; 135 } 136 137 SevenSignsFestival.getInstance().setParticipants(npc.getFestivalOracle(), npc.getFestivalType(), activeChar.getParty()); 138 SevenSignsFestival.getInstance().addAccumulatedBonus(npc.getFestivalType(), stoneType, stoneCount); 139 140 npc.showChatWindow(activeChar, 2, "e", false); 141 break; 142 case 3: // Score Registration 143 // Check if the festival period is active, if not then don't register the score. 144 if (SevenSigns.getInstance().isSealValidationPeriod()) 145 { 146 npc.showChatWindow(activeChar, 3, "a", false); 147 return true; 148 } 149 150 // Check if a festival is in progress, if it is don't register the score. 151 if (SevenSignsFestival.getInstance().isFestivalInProgress()) 152 { 153 activeChar.sendMessage("You cannot register a score while a festival is in progress."); 154 return true; 155 } 156 157 // Check if the player is in a party. 158 if (!activeChar.isInParty()) 159 { 160 npc.showChatWindow(activeChar, 3, "b", false); 161 return true; 162 } 163 164 final List<Integer> prevParticipants = SevenSignsFestival.getInstance().getPreviousParticipants(npc.getFestivalOracle(), npc.getFestivalType()); 165 166 // Check if there are any past participants. 167 if ((prevParticipants == null) || prevParticipants.isEmpty() || !prevParticipants.contains(activeChar.getObjectId())) 168 { 169 npc.showChatWindow(activeChar, 3, "b", false); 170 return true; 171 } 172 173 // Check if this player was the party leader in the festival. 174 if (activeChar.getObjectId() != prevParticipants.get(0)) 175 { 176 npc.showChatWindow(activeChar, 3, "b", false); 177 return true; 178 } 179 180 final L2ItemInstance bloodOfferings = activeChar.getInventory().getItemByItemId(SevenSignsFestival.FESTIVAL_OFFERING_ID); 181 182 // Check if the player collected any blood offerings during the festival. 183 if (bloodOfferings == null) 184 { 185 activeChar.sendMessage("You do not have any blood offerings to contribute."); 186 return true; 187 } 188 189 final long offeringScore = bloodOfferings.getCount() * SevenSignsFestival.FESTIVAL_OFFERING_VALUE; 190 if (!activeChar.destroyItem("SevenSigns", bloodOfferings, npc, false)) 191 { 192 return true; 193 } 194 195 final boolean isHighestScore = SevenSignsFestival.getInstance().setFinalScore(activeChar, npc.getFestivalOracle(), npc.getFestivalType(), offeringScore); 196 SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED_S1); 197 sm.addItemNumber(offeringScore); 198 activeChar.sendPacket(sm); 199 200 if (isHighestScore) 201 { 202 npc.showChatWindow(activeChar, 3, "c", false); 203 } 204 else 205 { 206 npc.showChatWindow(activeChar, 3, "d", false); 207 } 208 break; 209 case 4: // Current High Scores 210 final StringBuilder strBuffer = StringUtil.startAppend(500, "<html><body>Festival Guide:<br>These are the top scores of the week, for the "); 211 212 final StatsSet dawnData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DAWN, npc.getFestivalType()); 213 final StatsSet duskData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DUSK, npc.getFestivalType()); 214 final StatsSet overallData = SevenSignsFestival.getInstance().getOverallHighestScoreData(npc.getFestivalType()); 215 216 final int dawnScore = dawnData.getInteger("score"); 217 final int duskScore = duskData.getInteger("score"); 218 int overallScore = 0; 219 220 // If no data is returned, assume there is no record, or all scores are 0. 221 if (overallData != null) 222 { 223 overallScore = overallData.getInteger("score"); 224 } 225 226 StringUtil.append(strBuffer, SevenSignsFestival.getFestivalName(npc.getFestivalType()), " festival.<br>"); 227 228 if (dawnScore > 0) 229 { 230 StringUtil.append(strBuffer, "Dawn: ", calculateDate(dawnData.getString("date")), ". Score ", String.valueOf(dawnScore), "<br>", dawnData.getString("members"), "<br>"); 231 } 232 else 233 { 234 strBuffer.append("Dawn: No record exists. Score 0<br>"); 235 } 236 237 if (duskScore > 0) 238 { 239 StringUtil.append(strBuffer, "Dusk: ", calculateDate(duskData.getString("date")), ". Score ", String.valueOf(duskScore), "<br>", duskData.getString("members"), "<br>"); 240 } 241 else 242 { 243 strBuffer.append("Dusk: No record exists. Score 0<br>"); 244 } 245 246 if (overallScore > 0) 247 { 248 final String cabalStr; 249 if (overallData.getString("cabal").equals("dawn")) 73 250 { 74 npc.showChatWindow(activeChar, 2, "a", false); 75 return true; 76 } 77 78 // Check if a festival is in progress, then don't allow registration yet. 79 if (SevenSignsFestival.getInstance().isFestivalInitialized()) 80 { 81 activeChar.sendMessage("You cannot sign up while a festival is in progress."); 82 return true; 83 } 84 85 // Check if the player is in a formed party already. 86 if (!activeChar.isInParty()) 87 { 88 npc.showChatWindow(activeChar, 2, "b", false); 89 return true; 90 } 91 92 party = activeChar.getParty(); 93 94 // Check if the player is the party leader. 95 if (!party.isLeader(activeChar)) 96 { 97 npc.showChatWindow(activeChar, 2, "c", false); 98 return true; 99 } 100 101 // Check to see if the party has at least 5 members. 102 if (party.getMemberCount() < Config.ALT_FESTIVAL_MIN_PLAYER) 103 { 104 npc.showChatWindow(activeChar, 2, "b", false); 105 return true; 106 } 107 108 // Check if all the party members are in the required level range. 109 if (party.getLevel() > SevenSignsFestival.getMaxLevelForFestival(npc.getFestivalType())) 110 { 111 npc.showChatWindow(activeChar, 2, "d", false); 112 return true; 113 } 114 115 // Check to see if the player has already signed up 116 if (activeChar.isFestivalParticipant()) 117 { 118 SevenSignsFestival.getInstance().setParticipants(npc.getFestivalOracle(), npc.getFestivalType(), party); 119 npc.showChatWindow(activeChar, 2, "f", false); 120 return true; 121 } 122 123 npc.showChatWindow(activeChar, 1, null, false); 124 break; 125 case 2: // Seal Stones 126 final int stoneType = Integer.parseInt(command.substring(11)); 127 final int stoneCount = npc.getStoneCount(stoneType); 128 if (stoneCount <= 0) 129 { 130 return false; 131 } 132 133 if (!activeChar.destroyItemByItemId("SevenSigns", stoneType, stoneCount, npc, true)) 134 { 135 return false; 136 } 137 138 SevenSignsFestival.getInstance().setParticipants(npc.getFestivalOracle(), npc.getFestivalType(), activeChar.getParty()); 139 SevenSignsFestival.getInstance().addAccumulatedBonus(npc.getFestivalType(), stoneType, stoneCount); 140 141 npc.showChatWindow(activeChar, 2, "e", false); 142 break; 143 case 3: // Score Registration 144 // Check if the festival period is active, if not then don't register the score. 145 if (SevenSigns.getInstance().isSealValidationPeriod()) 146 { 147 npc.showChatWindow(activeChar, 3, "a", false); 148 return true; 149 } 150 151 // Check if a festival is in progress, if it is don't register the score. 152 if (SevenSignsFestival.getInstance().isFestivalInProgress()) 153 { 154 activeChar.sendMessage("You cannot register a score while a festival is in progress."); 155 return true; 156 } 157 158 // Check if the player is in a party. 159 if (!activeChar.isInParty()) 160 { 161 npc.showChatWindow(activeChar, 3, "b", false); 162 return true; 163 } 164 165 final List<Integer> prevParticipants = SevenSignsFestival.getInstance().getPreviousParticipants(npc.getFestivalOracle(), npc.getFestivalType()); 166 167 // Check if there are any past participants. 168 if ((prevParticipants == null) || prevParticipants.isEmpty() || !prevParticipants.contains(activeChar.getObjectId())) 169 { 170 npc.showChatWindow(activeChar, 3, "b", false); 171 return true; 172 } 173 174 // Check if this player was the party leader in the festival. 175 if (activeChar.getObjectId() != prevParticipants.get(0)) 176 { 177 npc.showChatWindow(activeChar, 3, "b", false); 178 return true; 179 } 180 181 final L2ItemInstance bloodOfferings = activeChar.getInventory().getItemByItemId(SevenSignsFestival.FESTIVAL_OFFERING_ID); 182 183 // Check if the player collected any blood offerings during the festival. 184 if (bloodOfferings == null) 185 { 186 activeChar.sendMessage("You do not have any blood offerings to contribute."); 187 return true; 188 } 189 190 final long offeringScore = bloodOfferings.getCount() * SevenSignsFestival.FESTIVAL_OFFERING_VALUE; 191 if (!activeChar.destroyItem("SevenSigns", bloodOfferings, npc, false)) 192 { 193 return true; 194 } 195 196 final boolean isHighestScore = SevenSignsFestival.getInstance().setFinalScore(activeChar, npc.getFestivalOracle(), npc.getFestivalType(), offeringScore); 197 SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED_S1); 198 sm.addItemNumber(offeringScore); 199 activeChar.sendPacket(sm); 200 201 if (isHighestScore) 202 { 203 npc.showChatWindow(activeChar, 3, "c", false); 251 cabalStr = "Children of Dawn"; 204 252 } 205 253 else 206 254 { 207 npc.showChatWindow(activeChar, 3, "d", false); 208 } 209 break; 210 case 4: // Current High Scores 211 final StringBuilder strBuffer = StringUtil.startAppend(500, "<html><body>Festival Guide:<br>These are the top scores of the week, for the "); 212 213 final StatsSet dawnData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DAWN, npc.getFestivalType()); 214 final StatsSet duskData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DUSK, npc.getFestivalType()); 215 final StatsSet overallData = SevenSignsFestival.getInstance().getOverallHighestScoreData(npc.getFestivalType()); 216 217 final int dawnScore = dawnData.getInteger("score"); 218 final int duskScore = duskData.getInteger("score"); 219 int overallScore = 0; 220 221 // If no data is returned, assume there is no record, or all scores are 0. 222 if (overallData != null) 223 { 224 overallScore = overallData.getInteger("score"); 255 cabalStr = "Children of Dusk"; 225 256 } 226 257 227 StringUtil.append(strBuffer, SevenSignsFestival.getFestivalName(npc.getFestivalType()), " festival.<br>"); 228 229 if (dawnScore > 0) 258 StringUtil.append(strBuffer, "Consecutive top scores: ", calculateDate(overallData.getString("date")), ". Score ", String.valueOf(overallScore), "<br>Affilated side: ", cabalStr, "<br>", overallData.getString("members"), "<br>"); 259 } 260 else 261 { 262 strBuffer.append("Consecutive top scores: No record exists. Score 0<br>"); 263 } 264 265 StringUtil.append(strBuffer, "<a action=\"bypass -h npc_", String.valueOf(npc.getObjectId()), "_Chat 0\">Go back.</a></body></html>"); 266 267 NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); 268 html.setHtml(strBuffer.toString()); 269 activeChar.sendPacket(html); 270 break; 271 case 8: // Increase the Festival Challenge 272 if (!activeChar.isInParty()) 273 { 274 return true; 275 } 276 277 if (!SevenSignsFestival.getInstance().isFestivalInProgress()) 278 { 279 return true; 280 } 281 282 party = activeChar.getParty(); 283 if (!party.isLeader(activeChar)) 284 { 285 npc.showChatWindow(activeChar, 8, "a", false); 286 return true; 287 } 288 289 if (SevenSignsFestival.getInstance().increaseChallenge(npc.getFestivalOracle(), npc.getFestivalType())) 290 { 291 npc.showChatWindow(activeChar, 8, "b", false); 292 } 293 else 294 { 295 npc.showChatWindow(activeChar, 8, "c", false); 296 } 297 break; 298 case 9: // Leave the Festival 299 if (!activeChar.isInParty()) 300 { 301 return true; 302 } 303 304 party = activeChar.getParty(); 305 if (party.isLeader(activeChar)) 306 { 307 SevenSignsFestival.getInstance().updateParticipants(activeChar, null); 308 } 309 else 310 { 311 if (party.getMemberCount() > Config.ALT_FESTIVAL_MIN_PLAYER) 230 312 { 231 StringUtil.append(strBuffer, "Dawn: ", calculateDate(dawnData.getString("date")), ". Score ", String.valueOf(dawnScore), "<br>", dawnData.getString("members"), "<br>");313 party.removePartyMember(activeChar, messageType.Expelled); 232 314 } 233 315 else 234 316 { 235 strBuffer.append("Dawn: No record exists. Score 0<br>");317 activeChar.sendMessage("Only the party leader can leave a festival when a party has minimum number of members."); 236 318 } 237 238 if (duskScore > 0) 239 { 240 StringUtil.append(strBuffer, "Dusk: ", calculateDate(duskData.getString("date")), ". Score ", String.valueOf(duskScore), "<br>", duskData.getString("members"), "<br>"); 241 } 242 else 243 { 244 strBuffer.append("Dusk: No record exists. Score 0<br>"); 245 } 246 247 if (overallScore > 0) 248 { 249 final String cabalStr; 250 if (overallData.getString("cabal").equals("dawn")) 251 { 252 cabalStr = "Children of Dawn"; 253 } 254 else 255 { 256 cabalStr = "Children of Dusk"; 257 } 258 259 StringUtil.append(strBuffer, "Consecutive top scores: ", calculateDate(overallData.getString("date")), ". Score ", String.valueOf(overallScore), "<br>Affilated side: ", cabalStr, "<br>", overallData.getString("members"), "<br>"); 260 } 261 else 262 { 263 strBuffer.append("Consecutive top scores: No record exists. Score 0<br>"); 264 } 265 266 StringUtil.append(strBuffer, "<a action=\"bypass -h npc_", String.valueOf(npc.getObjectId()), "_Chat 0\">Go back.</a></body></html>"); 267 268 NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); 269 html.setHtml(strBuffer.toString()); 270 activeChar.sendPacket(html); 271 break; 272 case 8: // Increase the Festival Challenge 273 if (!activeChar.isInParty()) 274 { 275 return true; 276 } 277 278 if (!SevenSignsFestival.getInstance().isFestivalInProgress()) 279 { 280 return true; 281 } 282 283 party = activeChar.getParty(); 284 if (!party.isLeader(activeChar)) 285 { 286 npc.showChatWindow(activeChar, 8, "a", false); 287 return true; 288 } 289 290 if (SevenSignsFestival.getInstance().increaseChallenge(npc.getFestivalOracle(), npc.getFestivalType())) 291 { 292 npc.showChatWindow(activeChar, 8, "b", false); 293 } 294 else 295 { 296 npc.showChatWindow(activeChar, 8, "c", false); 297 } 298 break; 299 case 9: // Leave the Festival 300 if (!activeChar.isInParty()) 301 { 302 return true; 303 } 304 305 party = activeChar.getParty(); 306 if (party.isLeader(activeChar)) 307 { 308 SevenSignsFestival.getInstance().updateParticipants(activeChar, null); 309 } 310 else 311 { 312 if (party.getMemberCount() > Config.ALT_FESTIVAL_MIN_PLAYER) 313 { 314 party.removePartyMember(activeChar, messageType.Expelled); 315 } 316 else 317 { 318 activeChar.sendMessage("Only the party leader can leave a festival when a party has minimum number of members."); 319 } 320 } 321 break; 322 case 0: // Distribute Accumulated Bonus 323 if (!SevenSigns.getInstance().isSealValidationPeriod()) 324 { 325 activeChar.sendMessage("Bonuses cannot be paid during the competition period."); 326 return true; 327 } 328 329 if (SevenSignsFestival.getInstance().distribAccumulatedBonus(activeChar) > 0) 330 { 331 npc.showChatWindow(activeChar, 0, "a", false); 332 } 333 else 334 { 335 npc.showChatWindow(activeChar, 0, "b", false); 336 } 337 break; 338 default: 339 npc.showChatWindow(activeChar, val, null, false); 340 } 319 } 320 break; 321 case 0: // Distribute Accumulated Bonus 322 if (!SevenSigns.getInstance().isSealValidationPeriod()) 323 { 324 activeChar.sendMessage("Bonuses cannot be paid during the competition period."); 325 return true; 326 } 327 328 if (SevenSignsFestival.getInstance().distribAccumulatedBonus(activeChar) > 0) 329 { 330 npc.showChatWindow(activeChar, 0, "a", false); 331 } 332 else 333 { 334 npc.showChatWindow(activeChar, 0, "b", false); 335 } 336 break; 337 default: 338 npc.showChatWindow(activeChar, val, null, false); 341 339 } 342 340 return true;
Note: See TracChangeset
for help on using the changeset viewer.
