Guest User

Untitled

a guest
Dec 9th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.40 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java   (revision 0)
  6. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java   (revision 0)
  7. @@ -0,0 +1,469 @@
  8. +package net.sf.l2j.gameserver.model.actor.instance;
  9. +
  10. +import javolution.text.TextBuilder;
  11. +
  12. +import net.sf.l2j.gameserver.ai.CtrlIntention;
  13. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  14. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  15. +import net.sf.l2j.gameserver.network.serverpackets.SetupGauge;
  16. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  17. +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  18. +import net.sf.l2j.gameserver.ThreadPoolManager;
  19. +import net.sf.l2j.gameserver.util.Broadcast;
  20. +import net.sf.l2j.util.Rnd;
  21. +
  22. +public class L2CasinoInstance extends L2NpcInstance
  23. +{
  24. +    public String filename;
  25. +
  26. +    public L2CasinoInstance(int objectId, L2NpcTemplate template)
  27. +    {
  28. +        super(objectId, template);
  29. +    }
  30. +
  31. +    @Override
  32. +    public void onBypassFeedback(L2PcInstance player, String command)
  33. +    {
  34. +        if(player == null)
  35. +            return;
  36. +
  37. +        if(command.startsWith("play1") && player.getInventory().getInventoryItemCount(9142, 0) >= 2)
  38. +            Casino1(player);
  39. +        if(command.startsWith("play2") && player.getInventory().getInventoryItemCount(9142, 0) >= 4)
  40. +            Casino2(player);
  41. +        if(command.startsWith("play3") && player.getInventory().getInventoryItemCount(9142, 0) >= 8)
  42. +            Casino3(player);
  43. +        if(command.startsWith("play4") && player.getInventory().getInventoryItemCount(9142, 0) >= 16)
  44. +            Casino4(player);
  45. +        if(command.startsWith("play5") && player.getInventory().getInventoryItemCount(57, 0) >= 500000)
  46. +            Casino5(player);
  47. +        if(command.startsWith("play6") && player.getInventory().getInventoryItemCount(57, 0) >= 1000000)
  48. +            Casino6(player);
  49. +        if(command.startsWith("play7") && player.getInventory().getInventoryItemCount(57, 0) >= 10000000)
  50. +            Casino7(player);
  51. +    }
  52. +
  53. +    public static void displayCongrats(L2PcInstance player)
  54. +    {
  55. +        player.broadcastPacket(new SocialAction(player, 3));
  56. +        MagicSkillUse  MSU = new MagicSkillUse(player, player, 2024, 1, 1, 0);
  57. +        player.broadcastPacket(MSU);
  58. +        player.sendMessage("Congratulations! you won");
  59. +    }
  60. +
  61. +    @Override
  62. +    public void showChatWindow(L2PcInstance player, int val)
  63. +    {
  64. +        filename = (getHtmlPath(getNpcId(), val));
  65. +        NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
  66. +        msg.setHtml(casinoWindow(player));
  67. +        msg.replace("%objectId%", String.valueOf(this.getObjectId()));
  68. +        player.sendPacket(msg);
  69. +    }
  70. +
  71. +    private String casinoWindow(L2PcInstance player)
  72. +    {
  73. +        TextBuilder tb = new TextBuilder();
  74. +        tb.append("<html><title>Casino Manager</title><body>");
  75. +        tb.append("<center>");
  76. +        tb.append("<br>");
  77. +        tb.append("<font color=\"999999\">Chance to win : 50%</font><br>");
  78. +        tb.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"><br>");
  79. +        tb.append("Welcome "+player.getName()+"<br>");
  80. +        tb.append("<tr><td>Double or Nothing ?</td></tr><br>");
  81. +        tb.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>");
  82. +        tb.append("<center>");
  83. +        tb.append("Place your bets");
  84. +        tb.append("</center>");
  85. +        tb.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>");
  86. +        tb.append("<br>");
  87. +        tb.append("<center>");
  88. +        tb.append("<tr>");
  89. +        tb.append("<td><button value=\"2 Apiga\" action=\"bypass -h npc_%objectId%_play1\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  90. +        tb.append("<td><button value=\"4 Apiga\" action=\"bypass -h npc_%objectId%_play2\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  91. +        tb.append("</tr>");
  92. +        tb.append("<tr>");
  93. +        tb.append("<td><button value=\"8 Apiga\" action=\"bypass -h npc_%objectId%_play3\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  94. +        tb.append("<td><button value=\"16 Apiga\" action=\"bypass -h npc_%objectId%_play4\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  95. +        tb.append("</tr>");
  96. +        tb.append("<tr>");
  97. +        tb.append("<td><button value=\"500k\" action=\"bypass -h npc_%objectId%_play5\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  98. +        tb.append("<td><button value=\"1kk\" action=\"bypass -h npc_%objectId%_play6\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  99. +        tb.append("</tr>");
  100. +        tb.append("<tr>");
  101. +        tb.append("<td><button value=\"10kk\" action=\"bypass -h npc_%objectId%_play7\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>");
  102. +        tb.append("</tr>");
  103. +        tb.append("</center>");
  104. +        tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\">");
  105. +        tb.append("</body></html>");
  106. +        return tb.toString();
  107. +    }
  108. +
  109. +    public static void Casino1(L2PcInstance player)
  110. +    {
  111. +        int unstuckTimer = 1000;
  112. +        player.setTarget(player);
  113. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  114. +        player.disableAllSkills();
  115. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  116. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  117. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  118. +        player.sendPacket(sg);
  119. +
  120. +        Casino1 ef = new Casino1(player);
  121. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  122. +    }
  123. +
  124. +    static class Casino1 implements Runnable
  125. +    {
  126. +        private L2PcInstance _player;
  127. +        Casino1(L2PcInstance player)
  128. +        {
  129. +            _player = player;
  130. +        }
  131. +        public void run()
  132. +        {
  133. +            if(_player.isDead())
  134. +                return;
  135. +
  136. +            _player.setIsIn7sDungeon(false);
  137. +            _player.enableAllSkills();
  138. +            int chance = Rnd.get(2);
  139. +
  140. +            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 2)
  141. +            {
  142. +                if(chance == 0)
  143. +                {
  144. +                    displayCongrats(_player);
  145. +                    _player.getInventory().addItem("Adena", 9142, 2, _player, null);
  146. +                }
  147. +                if(chance == 1)
  148. +                {
  149. +                   _player.sendMessage("You lost the bet");
  150. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 2, _player, null);
  151. +                }
  152. +            }
  153. +            else
  154. +                _player.sendMessage("You do not have eneough items.");
  155. +        }
  156. +    }
  157. +
  158. +    public static void Casino2(L2PcInstance player)
  159. +    {
  160. +        int unstuckTimer = 1000;
  161. +        player.setTarget(player);
  162. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  163. +        player.disableAllSkills();
  164. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  165. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  166. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  167. +        player.sendPacket(sg);
  168. +
  169. +        Casino2 ef = new Casino2(player);
  170. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  171. +    }
  172. +
  173. +    static class Casino2 implements Runnable
  174. +    {
  175. +        private L2PcInstance _player;
  176. +        Casino2(L2PcInstance player)
  177. +        {
  178. +            _player = player;
  179. +        }
  180. +        public void run()
  181. +        {
  182. +            if(_player.isDead())
  183. +                return;
  184. +
  185. +            _player.setIsIn7sDungeon(false);
  186. +            _player.enableAllSkills();
  187. +            int chance = Rnd.get(3);
  188. +
  189. +            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 4)
  190. +            {
  191. +                if(chance == 0)
  192. +                {
  193. +                    displayCongrats(_player);
  194. +                    _player.getInventory().addItem("Adena", 9142, 4, _player, null);
  195. +                }
  196. +                if(chance == 1)
  197. +                {
  198. +                   _player.sendMessage("You lost the bet");
  199. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 4, _player, null);
  200. +                }
  201. +                if(chance == 2)
  202. +                {
  203. +                   _player.sendMessage("You lost the bet");
  204. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 4, _player, null);
  205. +                }
  206. +            }
  207. +            else
  208. +               _player.sendMessage("You do not have eneough items.");
  209. +        }
  210. +    }
  211. +
  212. +    public static void Casino3(L2PcInstance player)
  213. +    {
  214. +        int unstuckTimer = 1000;
  215. +        player.setTarget(player);
  216. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  217. +        player.disableAllSkills();
  218. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  219. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  220. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  221. +        player.sendPacket(sg);
  222. +
  223. +        Casino3 ef = new Casino3(player);
  224. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  225. +    }
  226. +
  227. +    static class Casino3 implements Runnable
  228. +    {
  229. +        private L2PcInstance _player;
  230. +        Casino3(L2PcInstance player)
  231. +        {
  232. +            _player = player;
  233. +        }
  234. +        public void run()
  235. +        {
  236. +            if(_player.isDead())
  237. +                return;
  238. +
  239. +            _player.setIsIn7sDungeon(false);
  240. +            _player.enableAllSkills();
  241. +            int chance = Rnd.get(3);
  242. +
  243. +            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 8)
  244. +            {
  245. +                if(chance == 0)
  246. +                {
  247. +                    displayCongrats(_player);
  248. +                    _player.getInventory().addItem("Adena", 9142, 8, _player, null);
  249. +                }
  250. +                if(chance == 1)
  251. +                {
  252. +                   _player.sendMessage("You lost the bet");
  253. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 8, _player, null);
  254. +                }
  255. +                if(chance == 2)
  256. +                {
  257. +                   _player.sendMessage("You lost the bet");
  258. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 8, _player, null);
  259. +                }
  260. +            }
  261. +            else
  262. +               _player.sendMessage("You do not have eneough items.");
  263. +        }
  264. +    }
  265. +
  266. +    public static void Casino4(L2PcInstance player)
  267. +    {
  268. +        int unstuckTimer = 1000;
  269. +        player.setTarget(player);
  270. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  271. +        player.disableAllSkills();
  272. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  273. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  274. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  275. +        player.sendPacket(sg);
  276. +
  277. +        Casino4 ef = new Casino4(player);
  278. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  279. +    }
  280. +
  281. +    static class Casino4 implements Runnable
  282. +    {
  283. +        private L2PcInstance _player;
  284. +        Casino4(L2PcInstance player)
  285. +        {
  286. +            _player = player;
  287. +        }
  288. +        public void run()
  289. +        {
  290. +            if(_player.isDead())
  291. +                return;
  292. +
  293. +            _player.setIsIn7sDungeon(false);
  294. +            _player.enableAllSkills();
  295. +            int chance = Rnd.get(3);
  296. +
  297. +            if(_player.getInventory().getInventoryItemCount(9142, 0) >= 16)
  298. +            {
  299. +                if(chance == 0)
  300. +                {
  301. +                    displayCongrats(_player);
  302. +                    _player.getInventory().addItem("Adena", 9142, 16, _player, null);
  303. +                }
  304. +                if(chance == 1)
  305. +                {
  306. +                   _player.sendMessage("You lost the bet");
  307. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 16, _player, null);
  308. +                }
  309. +                if(chance == 2)
  310. +                {
  311. +                   _player.sendMessage("You lost the bet");
  312. +                    _player.getInventory().destroyItemByItemId("Adena", 9142, 16, _player, null);
  313. +                }
  314. +            }
  315. +            else
  316. +               _player.sendMessage("You do not have eneough items.");
  317. +        }
  318. +    }
  319. +    
  320. +    public static void Casino5(L2PcInstance player)
  321. +    {
  322. +        int unstuckTimer = 1000;
  323. +        player.setTarget(player);
  324. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  325. +        player.disableAllSkills();
  326. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  327. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  328. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  329. +        player.sendPacket(sg);
  330. +
  331. +        Casino5 ef = new Casino5(player);
  332. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  333. +    }
  334. +
  335. +    static class Casino5 implements Runnable
  336. +    {
  337. +        private L2PcInstance _player;
  338. +        Casino5(L2PcInstance player)
  339. +        {
  340. +            _player = player;
  341. +        }
  342. +        public void run()
  343. +        {
  344. +            if(_player.isDead())
  345. +                return;
  346. +
  347. +            _player.setIsIn7sDungeon(false);
  348. +            _player.enableAllSkills();
  349. +            int chance = Rnd.get(2);
  350. +
  351. +            if(_player.getInventory().getInventoryItemCount(57, 0) >= 500000)
  352. +            {
  353. +                if(chance == 0)
  354. +                {
  355. +                    displayCongrats(_player);
  356. +                    _player.getInventory().addItem("Adena", 57, 500000, _player, null);
  357. +                }
  358. +                if(chance == 1)
  359. +                {
  360. +                   _player.sendMessage("You lost the bet");
  361. +                    _player.getInventory().destroyItemByItemId("Adena", 57, 500000, _player, null);
  362. +                }
  363. +            }
  364. +            else
  365. +               _player.sendMessage("You do not have eneough items.");
  366. +        }
  367. +    }
  368. +    
  369. +    public static void Casino6(L2PcInstance player)
  370. +    {
  371. +        int unstuckTimer = 1000;
  372. +        player.setTarget(player);
  373. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  374. +        player.disableAllSkills();
  375. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  376. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  377. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  378. +        player.sendPacket(sg);
  379. +
  380. +        Casino6 ef = new Casino6(player);
  381. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  382. +    }
  383. +
  384. +    static class Casino6 implements Runnable
  385. +    {
  386. +        private L2PcInstance _player;
  387. +        Casino6(L2PcInstance player)
  388. +        {
  389. +            _player = player;
  390. +        }
  391. +        public void run()
  392. +        {
  393. +            if(_player.isDead())
  394. +                return;
  395. +
  396. +            _player.setIsIn7sDungeon(false);
  397. +            _player.enableAllSkills();
  398. +            int chance = Rnd.get(3);
  399. +
  400. +            if(_player.getInventory().getInventoryItemCount(57, 0) >= 1000000)
  401. +            {
  402. +                if(chance == 0)
  403. +                {
  404. +                    displayCongrats(_player);
  405. +                    _player.getInventory().addItem("Adena", 57, 1000000, _player, null);
  406. +                }
  407. +                if(chance == 1)
  408. +                {
  409. +                   _player.sendMessage("You lost the bet");
  410. +                    _player.getInventory().destroyItemByItemId("Adena", 57, 1000000, _player, null);
  411. +                }
  412. +                if(chance == 2)
  413. +                {
  414. +                   _player.sendMessage("You lost the bet");
  415. +                    _player.getInventory().destroyItemByItemId("Adena", 57, 1000000, _player, null);
  416. +                }
  417. +            }
  418. +            else
  419. +               _player.sendMessage("You do not have eneough items.");
  420. +        }
  421. +    }
  422. +    
  423. +    public static void Casino7(L2PcInstance player)
  424. +    {
  425. +        int unstuckTimer = 1000;
  426. +        player.setTarget(player);
  427. +        player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  428. +        player.disableAllSkills();
  429. +        MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0);
  430. +        Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000);
  431. +        SetupGauge sg = new SetupGauge(0, unstuckTimer);
  432. +        player.sendPacket(sg);
  433. +
  434. +        Casino7 ef = new Casino7(player);
  435. +        ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer);
  436. +    }
  437. +
  438. +    static class Casino7 implements Runnable
  439. +    {
  440. +        private L2PcInstance _player;
  441. +        Casino7(L2PcInstance player)
  442. +        {
  443. +            _player = player;
  444. +        }
  445. +        public void run()
  446. +        {
  447. +            if(_player.isDead())
  448. +                return;
  449. +
  450. +            _player.setIsIn7sDungeon(false);
  451. +            _player.enableAllSkills();
  452. +            int chance = Rnd.get(3);
  453. +
  454. +            if(_player.getInventory().getInventoryItemCount(57, 0) >= 10000000)
  455. +            {
  456. +                if(chance == 0)
  457. +                {
  458. +                    displayCongrats(_player);
  459. +                    _player.getInventory().addItem("Adena", 57, 10000000, _player, null);
  460. +                }
  461. +                if(chance == 1)
  462. +                {
  463. +                   _player.sendMessage("You lost the bet");
  464. +                    _player.getInventory().destroyItemByItemId("Adena", 57, 10000000, _player, null);
  465. +                }
  466. +                if(chance == 2)
  467. +                {
  468. +                   _player.sendMessage("You lost the bet");
  469. +                    _player.getInventory().destroyItemByItemId("Adena", 57, 10000000, _player, null);
  470. +                }
  471. +            }
  472. +            else
  473. +               _player.sendMessage("You do not have eneough items.");
  474. +        }
  475. +    }
  476. +}
  477. \ No newline at end of file
Add Comment
Please, Sign In to add comment