Browse Source

JYTHON: Adding quest 662 : A Game of Cards. Thanks minlexx

Emperorc 17 years ago
parent
commit
14ed04b62b

+ 1 - 0
datapack_development/data/scripts.cfg

@@ -464,6 +464,7 @@ quests/653_WildMaiden/__init__.py
 quests/659_IdRatherBeCollectingFairyBreath/__init__.py
 quests/660_AidingtheFloranVillage/__init__.py
 quests/661_TheHarvestGroundsSafe/__init__.py
+quests/662_AGameOfCards/__init__.py
 quests/663_SeductiveWhispers/__init__.py
 quests/688_DefeatTheElrokianRaiders/__init__.py
 quests/998_FallenAngelSelect/__init__.py

+ 16 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_AcceptQuest.htm

@@ -0,0 +1,16 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Alrightly, then. Go bring me red gems! You can get the red gems by slaying 
+<font color="LEVEL">Tulben, Hames orc Scout, Hames Orc Footman, 
+Cursed Guardian, Hames Orc Overlord, Doom Scout, Dismal Pole, 
+Doom Servant, Doom Archer, Doom Warrior, Blood Queen, Trives, 
+Falibati, Doom Knight, Ghostly Warrior, Bloody Priest, Bloody Knight, 
+Dark Guard, Death Agent, Black Shadow, Chimera Piece, Nonexistent Man, 
+Forgotten Ancient People, Shaman of Ancient Times, Antelope, Buffalo, 
+Eye of Splendor, Wisdom of Splendor, Victory of Splendor, Signet of Splendor, 
+Splinter Stakato, Splinter Stakato Soldier, Needle Stakato and 
+Needle Stakato Soldier.</font> To play the game once, you'll need 
+to bring me <font color="LEVEL">50 Red Gems</font>. May the goddess 
+of luck go with you, youngster!
+</font>
+</body></html>

+ 4 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_ExitQuest.htm

@@ -0,0 +1,4 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Alright, come to play again if you wish!
+</body></html>

+ 15 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_FirstTalk.htm

@@ -0,0 +1,15 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Are you here because you heard the rumor, too? 
+These days, I spend a lot of my time playing cards with the 
+travelers who pass this way. Naturally, there's plenty of 
+reward for those who play a good game. Feel up to a game?<br>
+<br>
+Of course, since you stand to win a fair amount, you can't 
+play for free. That's why it's a game of chance, eh? If you 
+want to play with me, bring me some of those red gems that 
+have recently caught my eye. What do you say? Will you bring me 
+the gems so we can begin?
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_AcceptQuest.htm">Say yes.</a>
+</body></html>

+ 8 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_ListenCardsStory.htm

@@ -0,0 +1,8 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Actually, a fellow named Hindemith left these cards. Looks 
+like they have some kind of message on them, but I have no 
+idea what that means... I just use them to play cards... Ha ha ha!
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_QuestInProgress.htm">Return.</a><br>
+</body></html>

+ 15 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_ListenMobsList.htm

@@ -0,0 +1,15 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+You can get the red gems by slaying 
+<font color="LEVEL">Tulben, Hames orc Scout, Hames Orc Footman, 
+Cursed Guardian, Hames Orc Overlord, Doom Scout, Dismal Pole, 
+Doom Servant, Doom Archer, Doom Warrior, Blood Queen, Trives, 
+Falibati, Doom Knight, Ghostly Warrior, Bloody Priest, Bloody Knight, 
+Dark Guard, Death Agent, Black Shadow, Chimera Piece, Nonexistent Man, 
+Forgotten Ancient People, Shaman of Ancient Times, Antelope, Buffalo, 
+Eye of Splendor, Wisdom of Splendor, Victory of Splendor, Signet of Splendor, 
+Splinter Stakato, Splinter Stakato Soldier, Needle Stakato and 
+Needle Stakato Soldier.</font><br>
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_QuestInProgress.htm">Return.</a><br>
+</body></html>

+ 21 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_ListenPlayRules.htm

@@ -0,0 +1,21 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+It's very simple. There are 70 cards, made up of 5 suits 
+with 14 characters in each suit. You can draw 5 cards from the 
+lot, and if you get one of the combination of cards below, 
+you can be rewarded.<br>
+<br>
+Five of a kind: Five cards containing the same character.<br>
+Four of a kind: Four cards containing the same character.<br>
+Full house: Three cards with the same character along with two cards with the same character.<br>
+Three of a kind: Three cards with the same character.<br>
+Two pairs: Two pairs of cards with the same characters in each pair.<br>
+One pair: Two cards with the same charater.<br>
+<br>
+If you don't have any of the hands I just mentioned, it's called having 
+"no pair", and you don't get anything. Of course, a five of a kind is rare, 
+so the reward for getting it is high; on the other hand, one pair is the easiest 
+hand to get, so you'll receive only the lowest reward.
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_QuestInProgress.htm">Return.</a><br>
+</body></html>

+ 7 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_NoGems.htm

@@ -0,0 +1,7 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Unfortunately, you cannot play with me if you don't have 
+<font color="LEVEL">50 Red Gems</font>.<br>
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_QuestInProgress.htm">Return.</a><br>
+</body></html>

+ 7 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_PlayBegin.htm

@@ -0,0 +1,7 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Good thinking! Just let me shuffle the cards...
+<br>.<br>.<br>.<br>
+Ah, there we go! Would you like to cut the deck?<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_PlayField.htm">Cut the card deck.</a><br>
+</body></html>

+ 19 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_PlayField.htm

@@ -0,0 +1,19 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Check all 5 of your cards and then show them to me.<br>
+<table border="1" cellpadding="2"><tr>
+<td width="25" align="center"> CARD1 </td>
+<td width="25" align="center"> CARD2 </td>
+<td width="25" align="center"> CARD3 </td>
+<td width="25" align="center"> CARD4 </td>
+<td width="25" align="center"> CARD5 </td>
+</tr></table>
+<br>
+PRIZE<br>
+<br>
+LINK1
+LINK2
+LINK3
+LINK4
+LINK5
+</body></html>

+ 5 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_PlayNextTime.htm

@@ -0,0 +1,5 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Okay, come to me whenever you wish to play.
+<br>
+</body></html>

+ 21 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_QuestInProgress.htm

@@ -0,0 +1,21 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Hey, you do not have <font color="LEVEL">50 Red Gems</font>!<br>
+<br>
+Remember, you can get the red gems by slaying 
+<font color="LEVEL">Tulben, Hames orc Scout, Hames Orc Footman, 
+Cursed Guardian, Hames Orc Overlord, Doom Scout, Dismal Pole, 
+Doom Servant, Doom Archer, Doom Warrior, Blood Queen, Trives, 
+Falibati, Doom Knight, Ghostly Warrior, Bloody Priest, Bloody Knight, 
+Dark Guard, Death Agent, Black Shadow, Chimera Piece, Nonexistent Man, 
+Forgotten Ancient People, Shaman of Ancient Times, Antelope, Buffalo, 
+Eye of Splendor, Wisdom of Splendor, Victory of Splendor, Signet of Splendor, 
+Splinter Stakato, Splinter Stakato Soldier, Needle Stakato and 
+Needle Stakato Soldier.</font><br>
+<br>
+Return to me when you will have at least <font color="LEVEL">50 Red Gems</font>.<br>
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ListenPlayRules.htm">Listen to the explanation of the rules.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ListenCardsStory.htm">Listen to the story about the cards.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ExitQuest.htm">Cancel quest.</a><br>
+</body></html>

+ 12 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/Klump_QuestInProgress_Have50Gems.htm

@@ -0,0 +1,12 @@
+<html><body>Warehouse Chief Klump:<br>
+<br>
+Hey, you've brought <font color="LEVEL">50 Red Gems</font>. Terrific! 
+What do you say? Ready to play some cards?<br>
+<br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_PlayBegin.htm">Play cards.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_PlayNextTime.htm">Play next time.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ListenPlayRules.htm">Listen to the explanation of the rules.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ListenCardsStory.htm">Listen to the story about the cards.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ListenMobsList.htm">Ask about evil creatures that you can collect red gems from.</a><br>
+<a action="bypass -h Quest 662_AGameOfCards Klump_ExitQuest.htm">Cancel quest.</a><br>
+</body></html>

+ 165 - 0
datapack_development/data/scripts/quests/662_AGameOfCards/__init__.py

@@ -0,0 +1,165 @@
+# by minlexx
+# cleanup by Emperorc
+import sys
+from net.sf.l2j.gameserver.model.quest import State
+from net.sf.l2j.gameserver.model.quest import QuestState
+from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
+from net.sf.l2j.gameserver.cache import HtmCache
+
+qn = "662_AGameOfCards"
+
+KLUMP = 30845
+MOBS = [20677,21109,21112,21116,21114,21004,21002,21006,21008,21010,18001,20672,20673,20674,20955,\
+        20962,20961,20959,20958,20966,20965,20968,20973,20972,21278,21279,21280,21281,21286,21287,\
+        21288,21289,21520,21526,21530,21535,21508,21510,21513,21515]
+RED_GEM = 8765
+DROP_CHANCE = 60 # Drop chance for Red Gems
+
+# 14 cards; index 0 is for closed card, displayed as '?'
+CARD_VALUES = ["?","A","1","2","3","4","5","6","7","8","9","10","J","Q","K"]
+
+# Reward items
+ZIGGOS_GEMSTONE = 8868
+EWS = 959 # Scroll: Enchant Weapon S
+EWA = 729 # Scroll: Enchant Weapon A
+EWB = 947 # Scroll: Enchant Weapon B
+EWC = 951 # Scroll: Enchant Weapon C
+EWD = 955 # Scroll: Enchant Weapon D
+EAD = 956 # Scroll: Enchant Armor D
+
+#Rewards format - level : [[item1, amt1],[item2, amt2],...]
+REWARDS = {
+    6 : [[ZIGGOS_GEMSTONE,43],[EWS,3],[EWA,1]], # each Ziggo's Gemstone must be sellable to shops for 100 million adena
+    5 : [[EWS,2],[EWC,2]],                      # so, total adena reward in this case will be 4.3 billion adena
+    4 : [[EWA,1],[EWB,2],[EWD,1]],
+    3 : [[EWC,2]],
+    2 : [[EWC,1]],
+    1 : [[EAD,2]]
+}
+
+REWARDS_TEXT = [
+    "Hmmm...? This is... No pair? Tough luck, my friend! Want to try again? Perhaps your luck will take a turn for the better...",
+    "Hmmm...? This is... One pair? You got lucky this time, but I wonder if it'll last. Here's your prize.",
+    "Hmmm...? This is... Three of a kind? Very good, you are very lucky. Here's your prize.",
+    "Hmmm...? This is... Four of a kind! Well done, my young friend! That sort of hand doesn't come up very often, that's for sure. Here's your prize.",
+    "Hmmm...? This is... Five of a kind!!!! What luck! The goddess of victory must be with you! Here is your prize! Well earned, well played!",
+    "Hmmm...? This is... Two pairs? You got lucky this time, but I wonder if it'll last. Here's your prize.",
+    "Hmmm...? This is... A full house? Excellent! you're better than I thought. Here's your prize."
+]
+
+class Quest (JQuest) :
+
+ def __init__(self,id,name,descr):
+   JQuest.__init__(self,id,name,descr)
+   self.questItemIds = [RED_GEM]
+   self.games = {}
+
+ def onEvent (self,event,st) :
+     print event
+     htmltext = event
+     name = st.getPlayer().getName()
+     if event == "Klump_AcceptQuest.htm": # quest accepted
+         st.setState(State.STARTED)
+         st.playSound("ItemSound.quest_accept")
+         st.set("cond","1")
+     elif event == "Klump_ExitQuest.htm": # quest finished
+         st.playSound("ItemSound.quest_finish")
+         st.exitQuest(1)
+     elif event == "Klump_QuestInProgress.htm": # does player have 50 gems or not, different progress dialogs
+         if st.getQuestItemsCount(RED_GEM) >= 50 :
+             htmltext = "Klump_QuestInProgress_Have50Gems.htm" # this dialog allows playing
+     elif event == "Klump_PlayBegin.htm":
+         if st.getQuestItemsCount(RED_GEM) < 50:    # Not enough gems!!
+             return "Klump_NoGems.htm"
+         # on play begin remove 50 red gems
+         st.takeItems(RED_GEM,50) # take gems ...
+         self.games[name] = [0,0,0,0,0]
+     elif event == "Klump_PlayField.htm":
+         # get vars
+         card1,card2,card3,card4,card5 = self.games[name]
+         prize = 0
+         link1 = link2 = link3 = link4 = link5 = prizestr = ""
+         # if all cards are open, game ends and prize is given
+         if card1 and card2 and card3 and card4 and card5 : # Game ends
+             # make array of card indexes and sort it
+             ca = self.games[name]
+             ca.sort()
+             # now in sorted array all equal elements are near each other, for example [5,5, 3,3, 2] or [5, 4,4, 3,2]
+             # this makes much easier conditions checking
+             match = []
+             for i in range(len(ca)-1) :
+                 if ca[i] == ca[i+1] :
+                     prize += 1
+                     if not ca[i] in match :
+                         match.append(ca[i])
+             if len(match) == 2 :
+                 prize += 3
+             # prize = 1 : 1 pair (XX). 4 variants [XX---] [-XX--] [--XX-] [---XX]
+             # prize = 2 : 3 cards (XXX). 3 variants [XXX--] [-XXX-] [--XXX]
+             # prize = 3 : 4 cards (XXXX). 2 variants [XXXX-] [-XXXX]
+             # prize = 4 : 5 cards (XXXXX). 1 variant [XXXXX]
+             # prize = 5 : 2 pairs (XXYY). 3 variants [XXYY-] [XX-YY] [-XXYY]
+             # prize = 6 : Fullhouse (XXXYY). 2 variants [XXXYY] [YYXXX]
+             link1 = "<a action=\"bypass -h Quest 662_AGameOfCards Klump_QuestInProgress.htm\">Play again.</a><br>"
+             prizestr = REWARDS_TEXT[prize]
+         else : # game still in progress, display links
+           link1 = "Put the first card face up.<br>"
+           link2 = "Put the second card face up.<br>"
+           link3 = "Put the third card face up.<br>"
+           link4 = "Put the fourth card face up.<br>"
+           link5 = "Put the fifth card face up.<br>"
+           if card1 == 0: link1 = "<a action=\"bypass -h Quest 662_AGameOfCards Klump_openCard1.htm\">Put the first card face up.</a><br>"
+           if card2 == 0: link2 = "<a action=\"bypass -h Quest 662_AGameOfCards Klump_openCard2.htm\">Put the second card face up.</a><br>"
+           if card3 == 0: link3 = "<a action=\"bypass -h Quest 662_AGameOfCards Klump_openCard3.htm\">Put the third card face up.</a><br>"
+           if card4 == 0: link4 = "<a action=\"bypass -h Quest 662_AGameOfCards Klump_openCard4.htm\">Put the fourth card face up.</a><br>"
+           if card5 == 0: link5 = "<a action=\"bypass -h Quest 662_AGameOfCards Klump_openCard5.htm\">Put the fifth card face up.</a><br>"
+         htmltext = HtmCache.getInstance().getHtm("data/scripts/quests/" + qn + "/Klump_PlayField.htm")
+         htmltext = htmltext.replace("CARD1",CARD_VALUES[card1]).replace("CARD2",CARD_VALUES[card2]).replace("CARD3",CARD_VALUES[card3]).replace("CARD4",CARD_VALUES[card4]).replace("CARD5",CARD_VALUES[card5])
+         htmltext = htmltext.replace("LINK1",link1).replace("LINK2",link2).replace("LINK3",link3).replace("LINK4",link4).replace("LINK5",link5).replace("PRIZE",prizestr)
+         if prize :
+             for item,amt in REWARDS[prize] :
+                 st.giveItems(item,amt)
+     elif event.startswith("Klump_openCard") : # 'Open' card
+         num = int(event[14])
+         self.games[name][num-1] = st.getRandom(14) + 1 # generate index of random card, except index 0, which means 'card is closed'
+         htmltext = self.onEvent("Klump_PlayField.htm",st)
+     return htmltext
+
+ def onTalk (self,npc,player):
+     st = player.getQuestState(qn)
+     htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
+     if not st : return htmltext
+     npcId = npc.getNpcId()
+     id = st.getState()
+     # first talk to Klump, all quest begins here
+     if id == State.CREATED:
+         if player.getLevel() >= 61 : # check player level
+             htmltext = "Klump_FirstTalk.htm"
+         else:
+             htmltext = "<html><body>This quest is for characters level 61 and above.</body></html>"
+             st.exitQuest(1)
+     # talk to Klump when quest already in progress
+     elif id == State.STARTED :
+         htmltext = "Klump_QuestInProgress.htm"
+         if st.getQuestItemsCount(RED_GEM) >= 50 :
+             htmltext = "Klump_QuestInProgress_Have50Gems.htm"
+     return htmltext
+
+ def onKill(self,npc,player,isPet):
+     st = player.getQuestState(qn)
+     if not st : return
+     if st.getState() != State.STARTED : return
+     npcId = npc.getNpcId()
+     if npcId in MOBS:
+         if st.getRandom(100) < DROP_CHANCE:
+             st.giveItems(RED_GEM,1)
+             st.playSound("ItemSound.quest_itemget")
+     return
+
+QUEST = Quest(662,qn,"A Game Of Cards")
+
+QUEST.addStartNpc(KLUMP)
+QUEST.addTalkId(KLUMP)
+
+for mobId in MOBS:
+  QUEST.addKillId(mobId)